Skip to content

Commit

Permalink
updated Para core to 1.44.0
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Feb 16, 2022
1 parent 84fd21f commit 0c0ab0a
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 80 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM adoptopenjdk/openjdk11:ubi-minimal-jre
FROM adoptopenjdk/openjdk11:alpine-jre

RUN mkdir -p /para/lib

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2021 Erudika LTD, https://erudika.com
Copyright 2022 Erudika LTD, https://erudika.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<dependency>
<groupId>com.erudika</groupId>
<artifactId>para-core</artifactId>
<version>1.43.3</version>
<version>1.44.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -90,7 +90,7 @@
<dependency>
<groupId>org.opensearch.client</groupId>
<artifactId>opensearch-rest-high-level-client</artifactId>
<version>1.2.3</version>
<version>1.2.4</version>
</dependency>

<!-- LOGGING -->
Expand Down
61 changes: 31 additions & 30 deletions src/main/java/com/erudika/para/server/search/ElasticSearch.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2013-2021 Erudika. https://erudika.com
* Copyright 2013-2022 Erudika. https://erudika.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,6 +26,7 @@
import com.erudika.para.core.search.Search;
import com.erudika.para.core.utils.Config;
import com.erudika.para.core.utils.Pager;
import com.erudika.para.core.utils.Para;
import com.erudika.para.core.utils.Utils;
import static com.erudika.para.server.search.ElasticSearchUtils.PROPS_PREFIX;
import static com.erudika.para.server.search.ElasticSearchUtils.convertQueryStringToNestedQuery;
Expand Down Expand Up @@ -101,7 +102,7 @@ public class ElasticSearch implements Search {
private DAO dao;

static {
if (Config.isSearchEnabled() && Config.getConfigParam("search", "").
if (Para.getConfig().isSearchEnabled() && Para.getConfig().getConfigParam("search", "").
equalsIgnoreCase(ElasticSearch.class.getSimpleName())) {
ElasticSearchUtils.initClient();
// set up automatic index creation and deletion
Expand Down Expand Up @@ -409,8 +410,8 @@ protected <P extends ParaObject> List<P> searchQuery(final String appid, SearchH
}
List<P> results = new ArrayList<P>(hits.getHits().length);
List<String> keys = new LinkedList<String>();
boolean readFromIndex = Config.getConfigBoolean("read_from_index", false);
boolean cleanupIndex = Config.getConfigBoolean("sync_index_with_db", true);
boolean readFromIndex = Para.getConfig().getConfigBoolean("read_from_index", false);
boolean cleanupIndex = Para.getConfig().getConfigBoolean("sync_index_with_db", true);
try {
for (SearchHit hit : hits) {
if (readFromIndex) {
Expand Down Expand Up @@ -481,7 +482,7 @@ protected SearchHits searchQueryRaw(String appid, String type, QueryBuilder quer
SortOrder order = page.isDesc() ? SortOrder.DESC : SortOrder.ASC;
int max = page.getLimit();
int pageNum = (int) page.getPage();
int start = (pageNum < 1 || pageNum > Config.MAX_PAGES) ? 0 : (pageNum - 1) * max;
int start = (pageNum < 1 || pageNum > Para.getConfig().maxPages()) ? 0 : (pageNum - 1) * max;

if (query == null) {
query = matchAllQuery();
Expand Down Expand Up @@ -624,12 +625,12 @@ private static void createIndexInternal(App app) {
if (app != null) {
String appid = app.getAppIdentifier();
if (app.isSharingIndex()) {
ElasticSearchUtils.addIndexAliasWithRouting(Config.getRootAppIdentifier(), appid);
ElasticSearchUtils.addIndexAliasWithRouting(Para.getConfig().getRootAppIdentifier(), appid);
} else {
int shards = app.isRootApp() ? Config.getConfigInt("es.shards", 2)
: Config.getConfigInt("es.shards_for_child_apps", 1);
int replicas = app.isRootApp() ? Config.getConfigInt("es.replicas", 0)
: Config.getConfigInt("es.replicas_for_child_apps", 0);
int shards = app.isRootApp() ? Para.getConfig().getConfigInt("es.shards", 2)
: Para.getConfig().getConfigInt("es.shards_for_child_apps", 1);
int replicas = app.isRootApp() ? Para.getConfig().getConfigInt("es.replicas", 0)
: Para.getConfig().getConfigInt("es.replicas_for_child_apps", 0);
ElasticSearchUtils.createIndex(appid, shards, replicas);
}
}
Expand All @@ -651,7 +652,7 @@ public void onFailure(Exception ex) {
logger.error("Failed to delete all objects in shared index for app '" + appid + "'", ex);
}
});
ElasticSearchUtils.removeIndexAlias(Config.getRootAppIdentifier(), appid);
ElasticSearchUtils.removeIndexAlias(Para.getConfig().getRootAppIdentifier(), appid);
} else {
ElasticSearchUtils.deleteIndex(appid);
}
Expand All @@ -662,7 +663,7 @@ public void onFailure(Exception ex) {

@Override
public void index(ParaObject object) {
indexAllInternal(Config.getRootAppIdentifier(), Collections.singletonList(object));
indexAllInternal(Para.getConfig().getRootAppIdentifier(), Collections.singletonList(object));
}

@Override
Expand All @@ -672,7 +673,7 @@ public void index(String appid, ParaObject object) {

@Override
public void unindex(ParaObject object) {
unindexAllInternal(Config.getRootAppIdentifier(), Collections.singletonList(object));
unindexAllInternal(Para.getConfig().getRootAppIdentifier(), Collections.singletonList(object));
}

@Override
Expand All @@ -682,7 +683,7 @@ public void unindex(String appid, ParaObject object) {

@Override
public <P extends ParaObject> void indexAll(List<P> objects) {
indexAllInternal(Config.getRootAppIdentifier(), objects);
indexAllInternal(Para.getConfig().getRootAppIdentifier(), objects);
}

@Override
Expand All @@ -692,7 +693,7 @@ public <P extends ParaObject> void indexAll(String appid, List<P> objects) {

@Override
public <P extends ParaObject> void unindexAll(List<P> objects) {
unindexAllInternal(Config.getRootAppIdentifier(), objects);
unindexAllInternal(Para.getConfig().getRootAppIdentifier(), objects);
}

@Override
Expand All @@ -702,7 +703,7 @@ public <P extends ParaObject> void unindexAll(String appid, List<P> objects) {

@Override
public void unindexAll(Map<String, ?> terms, boolean matchAll) {
unindexAllInternal(Config.getRootAppIdentifier(), terms, matchAll);
unindexAllInternal(Para.getConfig().getRootAppIdentifier(), terms, matchAll);
}

@Override
Expand All @@ -712,7 +713,7 @@ public void unindexAll(String appid, Map<String, ?> terms, boolean matchAll) {

@Override
public <P extends ParaObject> P findById(String id) {
return findByIdInternal(Config.getRootAppIdentifier(), id);
return findByIdInternal(Para.getConfig().getRootAppIdentifier(), id);
}

@Override
Expand All @@ -722,7 +723,7 @@ public <P extends ParaObject> P findById(String appid, String id) {

@Override
public <P extends ParaObject> List<P> findByIds(List<String> ids) {
return findByIdsInternal(Config.getRootAppIdentifier(), ids);
return findByIdsInternal(Para.getConfig().getRootAppIdentifier(), ids);
}

@Override
Expand All @@ -733,7 +734,7 @@ public <P extends ParaObject> List<P> findByIds(String appid, List<String> ids)
@Override
public <P extends ParaObject> List<P> findNearby(String type,
String query, int radius, double lat, double lng, Pager... pager) {
return findNearbyInternal(Config.getRootAppIdentifier(), type, query, radius, lat, lng, pager);
return findNearbyInternal(Para.getConfig().getRootAppIdentifier(), type, query, radius, lat, lng, pager);
}

@Override
Expand All @@ -744,7 +745,7 @@ public <P extends ParaObject> List<P> findNearby(String appid, String type,

@Override
public <P extends ParaObject> List<P> findPrefix(String type, String field, String prefix, Pager... pager) {
return findPrefixInternal(Config.getRootAppIdentifier(), type, field, prefix, pager);
return findPrefixInternal(Para.getConfig().getRootAppIdentifier(), type, field, prefix, pager);
}

@Override
Expand All @@ -754,7 +755,7 @@ public <P extends ParaObject> List<P> findPrefix(String appid, String type, Stri

@Override
public <P extends ParaObject> List<P> findQuery(String type, String query, Pager... pager) {
return findQueryInternal(Config.getRootAppIdentifier(), type, query, pager);
return findQueryInternal(Para.getConfig().getRootAppIdentifier(), type, query, pager);
}

@Override
Expand All @@ -764,7 +765,7 @@ public <P extends ParaObject> List<P> findQuery(String appid, String type, Strin

@Override
public <P extends ParaObject> List<P> findNestedQuery(String type, String field, String query, Pager... pager) {
return findNestedQueryInternal(Config.getRootAppIdentifier(), type, field, query, pager);
return findNestedQueryInternal(Para.getConfig().getRootAppIdentifier(), type, field, query, pager);
}

@Override
Expand All @@ -775,7 +776,7 @@ public <P extends ParaObject> List<P> findNestedQuery(String appid, String type,
@Override
public <P extends ParaObject> List<P> findSimilar(String type, String filterKey, String[] fields,
String liketext, Pager... pager) {
return findSimilarInternal(Config.getRootAppIdentifier(), type, filterKey, fields, liketext, pager);
return findSimilarInternal(Para.getConfig().getRootAppIdentifier(), type, filterKey, fields, liketext, pager);
}

@Override
Expand All @@ -786,7 +787,7 @@ public <P extends ParaObject> List<P> findSimilar(String appid, String type, Str

@Override
public <P extends ParaObject> List<P> findTagged(String type, String[] tags, Pager... pager) {
return findTaggedInternal(Config.getRootAppIdentifier(), type, tags, pager);
return findTaggedInternal(Para.getConfig().getRootAppIdentifier(), type, tags, pager);
}

@Override
Expand All @@ -796,7 +797,7 @@ public <P extends ParaObject> List<P> findTagged(String appid, String type, Stri

@Override
public <P extends ParaObject> List<P> findTags(String keyword, Pager... pager) {
return findTagsInternal(Config.getRootAppIdentifier(), keyword, pager);
return findTagsInternal(Para.getConfig().getRootAppIdentifier(), keyword, pager);
}

@Override
Expand All @@ -807,7 +808,7 @@ public <P extends ParaObject> List<P> findTags(String appid, String keyword, Pag
@Override
public <P extends ParaObject> List<P> findTermInList(String type, String field,
List<?> terms, Pager... pager) {
return findTermInListInternal(Config.getRootAppIdentifier(), type, field, terms, pager);
return findTermInListInternal(Para.getConfig().getRootAppIdentifier(), type, field, terms, pager);
}

@Override
Expand All @@ -819,7 +820,7 @@ public <P extends ParaObject> List<P> findTermInList(String appid, String type,
@Override
public <P extends ParaObject> List<P> findTerms(String type, Map<String, ?> terms,
boolean mustMatchBoth, Pager... pager) {
return findTermsInternal(Config.getRootAppIdentifier(), type, terms, mustMatchBoth, pager);
return findTermsInternal(Para.getConfig().getRootAppIdentifier(), type, terms, mustMatchBoth, pager);
}

@Override
Expand All @@ -831,7 +832,7 @@ public <P extends ParaObject> List<P> findTerms(String appid, String type, Map<S
@Override
public <P extends ParaObject> List<P> findWildcard(String type, String field, String wildcard,
Pager... pager) {
return findWildcardInternal(Config.getRootAppIdentifier(), type, field, wildcard, pager);
return findWildcardInternal(Para.getConfig().getRootAppIdentifier(), type, field, wildcard, pager);
}

@Override
Expand All @@ -842,7 +843,7 @@ public <P extends ParaObject> List<P> findWildcard(String appid, String type, St

@Override
public Long getCount(String type) {
return getCountInternal(Config.getRootAppIdentifier(), type);
return getCountInternal(Para.getConfig().getRootAppIdentifier(), type);
}

@Override
Expand All @@ -852,7 +853,7 @@ public Long getCount(String appid, String type) {

@Override
public Long getCount(String type, Map<String, ?> terms) {
return getCountInternal(Config.getRootAppIdentifier(), type, terms);
return getCountInternal(Para.getConfig().getRootAppIdentifier(), type, terms);
}

@Override
Expand Down
Loading

0 comments on commit 0c0ab0a

Please sign in to comment.