Skip to content

Commit

Permalink
updated Para configuration and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Apr 8, 2022
1 parent 2dc2c17 commit d2dcf79
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 1,593 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ para.search = "ElasticSearch"
This could be a Java system property or part of a `application.conf` file on the classpath.
This tells Para to use the Elasticsearch implementation instead of the default (Lucene).

### SSL connection with Elasticsearch

Newer versions of ES are using HTTPS by default and generate a unique SSL certificate on first startup.
To have a successful connection, you should first add the generated CA of the ES server to your Java keystore,
indicating that you trust that certificate. This is the console command to do that:

```sh
echo -n | \
openssl s_client -connect localhost:9200 | \
sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ./ca_elasticsearch.cer && \
keytool -import -alias saelk -file ca_elasticsearch.cer -keystore ${JAVA_HOME}/lib/security/cacerts -storepass changeit
```

Finally, set `para.es.restclient_scheme = "https"`.

### Synchronous versus Asynchronous Indexing
The Elasticsearch plugin supports both synchronous (default) and asynchronous indexing modes.
For synchronous indexing, the Elasticsearch plugin will make a single, blocking request through the client
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@
<skipTests>false</skipTests>
<skipITs>${skipTests}</skipITs>
<skipUTs>${skipTests}</skipUTs>
<elasticsearch.version>8.1.1</elasticsearch.version>
<elasticsearch.version>8.1.2</elasticsearch.version>
<jerseyVer>2.35</jerseyVer>
</properties>

<dependencies>
<dependency>
<groupId>com.erudika</groupId>
<artifactId>para-core</artifactId>
<version>1.45.3</version>
<version>1.45.7</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/erudika/para/server/search/ElasticSearch.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ public class ElasticSearch implements Search {
/**
* Switch between OpenSearch and Elasticsearch flavors.
*/
public static final boolean OPEN_SEARCH_FLAVOR = "opensearch".equalsIgnoreCase(Para.getConfig().
getConfigParam("es.flavor", "elasticsearch"));
public static final boolean OPEN_SEARCH_FLAVOR = "opensearch".
equalsIgnoreCase(Para.getConfig().elasticsearchFlavor());

static {
if (Para.getConfig().isSearchEnabled() && Para.getConfig().getConfigParam("search", "").
if (Para.getConfig().isSearchEnabled() && Para.getConfig().searchPlugin().
equalsIgnoreCase(ElasticSearch.class.getSimpleName())) {
// set up automatic index creation and deletion
App.addAppCreatedListener((App app) -> createIndexInternal(app));
Expand Down Expand Up @@ -123,10 +123,10 @@ private static void createIndexInternal(App app) {
ESUtils.addIndexAliasWithRouting(Para.getConfig().getRootAppIdentifier(), appid);
}
} else {
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);
int shards = app.isRootApp() ? Para.getConfig().elasticsearchRootIndexShards()
: Para.getConfig().elasticsearchChildIndexShards();
int replicas = app.isRootApp() ? Para.getConfig().elasticsearchRootIndexReplicas()
: Para.getConfig().elasticsearchChildIndexReplicas();
if (OPEN_SEARCH_FLAVOR) {
OSUtils.createIndex(appid, shards, replicas);
} else {
Expand Down
Loading

0 comments on commit d2dcf79

Please sign in to comment.