From 55456e50c98c1821c93c68b99ad5b7539e6808be Mon Sep 17 00:00:00 2001 From: Rob Vesse Date: Mon, 19 Feb 2024 11:19:29 +0000 Subject: [PATCH] Upgrade to ElasticSearch 7.17.18 Upgrades to latest ElasticSearch 7.17 release --- .github/workflows/dockerhub.yml | 13 + Dockerfile | 8 +- README.md | 34 +- pom.xml | 294 +++++++++--------- .../IndexedSynonymParserTest.java | 4 +- 5 files changed, 198 insertions(+), 155 deletions(-) diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index 2dfb70a..2573069 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -22,6 +22,16 @@ jobs: - name: Build with Maven run: mvn -B package --file pom.xml + + - name: Detect ElasticSearch Version + id: elasticsearch + run: | + echo version=$(mvn -q -Dexec.executable=echo -Dexec.args='${elasticsearch.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT + + - name: Detect Plugin Version + id: plugin + run: | + echo version=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) >> $GITHUB_OUTPUT - name: Log in to Docker Hub uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a @@ -54,3 +64,6 @@ jobs: file: ./Dockerfile tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + build-args: | + ELASTICSEARCH_VERSION=${{ steps.elasticsearch.outputs.version }} + PLUGIN_VERSION=${{ steps.plugin.outputs.version }} diff --git a/Dockerfile b/Dockerfile index 6d74a12..4fe4ee3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,5 @@ -FROM docker.elastic.co/elasticsearch/elasticsearch:7.17.5 -COPY target/releases/SynonymsPlugin-7.17.5.1.zip /tmp -RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/SynonymsPlugin-7.17.5.1.zip +ARG ELASTICSEARCH_VERSION +FROM docker.elastic.co/elasticsearch/elasticsearch:${ELASTICSEARCH_VERSION} +ARG PLUGIN_VERSION +COPY target/releases/SynonymsPlugin-${PLUGIN_VERSION}.zip /tmp +RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch file:///tmp/SynonymsPlugin-${PLUGIN_VERSION}.zip diff --git a/README.md b/README.md index 9844bd7..0974480 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,18 @@ ## Overview -This plugin provides an alternative implementation of the [SynonymGraphTokenFilter](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/analysis-synonym-graph-tokenfilter.html) for Elasticsearch. +This plugin provides an alternative implementation of the +[SynonymGraphTokenFilter](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/analysis-synonym-graph-tokenfilter.html) +for Elasticsearch. -Instead of storing the synonyms in a file, this implementation loads it from an Elasticsearch index, which makes it easier to update especially when Elasticsearch runs in a sandboxed environment or in a cluster as it saves you having to update the synonyms file on every node of the cluster. +Instead of storing the synonyms in a file, this implementation loads it from an Elasticsearch index, which makes it +easier to update especially when Elasticsearch runs in a sandboxed environment or in a cluster as it saves you having to +update the synonyms file on every node of the cluster. The main branch of this repository is for Elasticsearch 7.x, a separate branch is for 8.x. -This project is licensed under ASF license v2, see [LICENSE](LICENSE). All contributions are welcome and should be under ASF license v2, see [CONTRIBUTING](CONTRIBUTING.md) on how to proceed. +This project is licensed under ASF license v2, see [LICENSE](LICENSE). All contributions are welcome and should be under +ASF license v2, see [CONTRIBUTING](CONTRIBUTING.md) on how to proceed. ### Issues/Questions @@ -39,10 +44,11 @@ This is because the plugin code needs to query Elasticsearch and requires specia ## Docker -If you are planning to use Elasticsearch with Docker, you should build a custom version of the image using the Dockerfile provided and use it instead +If you are planning to use Elasticsearch with Docker, you should build a custom version of the image using the +Dockerfile provided and use it instead ``` -docker build --tag=elasticsearch-telicent-plugin:7.17.5 . +docker build --tag=elasticsearch-telicent-plugin:7.17.14 . ``` This way the plugin will be preinstalled. @@ -95,11 +101,14 @@ curl -XPUT "http://localhost:9200/my_index" -H 'Content-Type: application/json' ``` -The index synonym graph is used only during search and can't be applied during indexing. -The parameters _lenient_ and _expand_ are similar to those of synonym-graph-tokenfilter, their default values are indicated above. -The parameter _index_ specifies where the plugin will load the synonym mappings from. The default value is _.synonyms_. +The index synonym graph is used only during search and can't be applied during indexing. The parameters _lenient_ and +_expand_ are similar to those of synonym-graph-tokenfilter, their default values are indicated above. The parameter +_index_ specifies where the plugin will load the synonym mappings from. The default value is _.synonyms_. -The parameters "username" and "password" allow to specify the credentials to use for connecting to Elasticsearch. If the [security plugin is deactivated](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html), remove these parameters. +The parameters "username" and "password" allow to specify the credentials to use for connecting to Elasticsearch. If the +[security plugin is +deactivated](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html), remove these +parameters. The next step is to index the synonyms. @@ -118,11 +127,14 @@ curl -XPOST -H "Content-Type: application/json" "http://localhost:9200/.synonyms The plugin supports only the [SOLR format](https://www.elastic.co/guide/en/elasticsearch/reference/7.17/analysis-synonym-graph-tokenfilter.html#_solr_synonyms_2). -The synonyms can be stored in any number of documents in the index, a query loads them all. The field names do not matter either. The values of the fields are either simple strings or arrays of strings. Each string corresponds to a line in the SOLR synonym format. +The synonyms can be stored in any number of documents in the index, a query loads them all. The field names do not +matter either. The values of the fields are either simple strings or arrays of strings. Each string corresponds to a +line in the SOLR synonym format. ## Testing -Now that the synonym index has been populated, you can check that it is being applied. First, since the synonym data have been created *after* configuring the analysis for the search, the config must be reloaded with +Now that the synonym index has been populated, you can check that it is being applied. First, since the synonym data +have been created *after* configuring the analysis for the search, the config must be reloaded with ``` curl -XPOST "http://localhost:9200/my_index/_reload_search_analyzers" -u elastic:This1sAPassw0rd diff --git a/pom.xml b/pom.xml index 9cb6970..f18378a 100644 --- a/pom.xml +++ b/pom.xml @@ -1,142 +1,158 @@ - 4.0.0 - io.telicent.elasticsearch - SynonymsPlugin - 7.17.5.1 - A plugin for ElasticSearch providing an index-backed synonym - handler - - UTF-8 - 7.17.5 - 17 - 1.19.2 - 2.16.0 - 2.16.0 - 4.3 - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.1 - - ${jdk.version} - ${jdk.version} - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - process-resources - - copy-dependencies - - - runtime - ${project.build.directory}/lib - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - false - ${project.build.directory}/releases/ - - ${basedir}/src/main/assemblies/plugin.xml - - - - - package - - single - - - - - - com.cosium.code - git-code-format-maven-plugin - ${git-code-format-maven-plugin.version} - - - - install-formatter-hook - - install-hooks - - - - - validate-code-format - - validate-code-format - - - - - - - com.cosium.code - google-java-format - ${git-code-format-maven-plugin.version} - - - - - true - false - false - false - - - - - - - - com.fasterxml.jackson.core - jackson-core - ${jackson.core.version} - provided - - - com.fasterxml.jackson.core - jackson-databind - ${jackson.databind.version} - compile - - - org.elasticsearch - elasticsearch - ${elasticsearch.version} - provided - - - co.elastic.clients - elasticsearch-java - ${elasticsearch.version} - - - - org.testcontainers - elasticsearch - ${testcontainer.version} - test - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + io.telicent.elasticsearch + SynonymsPlugin + 7.17.18.0 + A plugin for ElasticSearch providing an index-backed synonym + handler + + + UTF-8 + 7.17.18 + 17 + 1.19.2 + 2.16.1 + 2.16.1 + 4.3 + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${jdk.version} + ${jdk.version} + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.2.5 + + + ${elasticsearch.version} + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + process-resources + + copy-dependencies + + + runtime + ${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + false + ${project.build.directory}/releases/ + + ${basedir}/src/main/assemblies/plugin.xml + + + + + package + + single + + + + + + com.cosium.code + git-code-format-maven-plugin + ${git-code-format-maven-plugin.version} + + + + install-formatter-hook + + install-hooks + + + + + validate-code-format + + validate-code-format + + + + + + + com.cosium.code + google-java-format + ${git-code-format-maven-plugin.version} + + + + + true + false + false + false + + + + + + + + com.fasterxml.jackson.core + jackson-core + ${jackson.core.version} + provided + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.databind.version} + compile + + + org.elasticsearch + elasticsearch + ${elasticsearch.version} + provided + + + co.elastic.clients + elasticsearch-java + ${elasticsearch.version} + + + + org.testcontainers + elasticsearch + ${testcontainer.version} + test + + + org.slf4j + slf4j-simple + 2.0.7 + + diff --git a/src/test/java/io/telicent/elasticsearch/IndexedSynonymParserTest.java b/src/test/java/io/telicent/elasticsearch/IndexedSynonymParserTest.java index 5da195a..85452c9 100644 --- a/src/test/java/io/telicent/elasticsearch/IndexedSynonymParserTest.java +++ b/src/test/java/io/telicent/elasticsearch/IndexedSynonymParserTest.java @@ -57,8 +57,8 @@ public class IndexedSynonymParserTest { private void setup(boolean authenticate) throws ElasticsearchException, IOException { - String version = System.getProperty("elasticsearch-version"); - if (version == null) version = "7.17.5"; + String version = System.getProperty("elasticsearch.version"); + if (version == null) version = "7.17.18"; LOG.info("Starting docker instance of Elasticsearch {}...", version); container =