Skip to content

Commit

Permalink
Merge pull request #11 from Telicent-io/elastic-update
Browse files Browse the repository at this point in the history
Upgrade to ElasticSearch 7.17.18
  • Loading branch information
rvesse authored Feb 19, 2024
2 parents 26503f5 + 55456e5 commit cbb77f0
Show file tree
Hide file tree
Showing 5 changed files with 198 additions and 155 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/dockerhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
34 changes: 23 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.

Expand All @@ -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
Expand Down
Loading

0 comments on commit cbb77f0

Please sign in to comment.