From 5893d6691ab6d99ce27882fbf87fe34a995ff30b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 4 Jun 2019 18:48:09 +0200 Subject: [PATCH 01/10] Add documentation about reloading search analyzers --- .../tokenfilters/synonym-tokenfilter.asciidoc | 41 ++++++++++++++ .../indices/reload-analyzers.asciidoc | 56 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 docs/reference/indices/reload-analyzers.asciidoc diff --git a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc index 139f7c3ab0ad0..8ffd41267a696 100644 --- a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc @@ -43,6 +43,10 @@ Additional settings are: * `expand` (defaults to `true`). * `lenient` (defaults to `false`). If `true` ignores exceptions while parsing the synonym configuration. It is important to note that only those synonym rules which cannot get parsed are ignored. For instance consider the following request: +* `updateable` (defaults to false). If `true`, this marks the filter to be updateable using the +<>, but it will also restrict the filter to only be usable in +<>. + [source,js] -------------------------------------------------- @@ -181,3 +185,40 @@ error. If you need to build analyzers that include both multi-token filters and synonym filters, consider using the <> filter, with the multi-token filters in one branch and the synonym filter in the other. + +=== Updateability of search time synonyms + +Synonym filters that are used in <> can be marked +as updateable using the `updateable` flag: + +[source,js] +-------------------------------------------------- +PUT /test_index +{ + "settings": { + "index" : { + "analysis" : { + "analyzer" : { + "synonym" : { + "tokenizer" : "whitespace", + "filter" : ["synonym"] + } + }, + "filter" : { + "synonym" : { + "type" : "synonym", + "synonyms_path" : "analysis/synonym.txt", + "updateable" : true + } + } + } + } + } +} +-------------------------------------------------- +// CONSOLE + +Using the <>, you can trigger reloading of the +synonym definition. The contents of the configured synonyms file will be reloaded and the +synonyms definition the filter uses will be updated. Note that if you trying to use the above +analyzer as an index analyzer will result in an error. \ No newline at end of file diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc new file mode 100644 index 0000000000000..ffdd5530d460b --- /dev/null +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -0,0 +1,56 @@ +[[indices-reload-analyzers]] +== Reload Search Analyzers + +Reloads search analyzers and its resources. + +The `_reload_search_analyzers` API can be run on one more indices and will +reload all search analyzers that contain components that were marked as +updateable when they were created, such as +<>: + +[source,js] +-------------------------------------------------- +PUT /test_index +{ + "settings": { + "index" : { + "analysis" : { + "analyzer" : { + "synonym" : { + "tokenizer" : "whitespace", + "filter" : ["synonym"] + } + }, + "filter" : { + "synonym" : { + "type" : "synonym", + "synonyms_path" : "analysis/synonym.txt", + "updateable" : true <1> + } + } + } + } + }, + "mappings": { + "properties": { + "text": { + "type": "text", + "search_analyzer": "synonym" <2> + } + } + } +} +-------------------------------------------------- +// CONSOLE + +<1> Mark the synonym filter as updateable. +<2> Synonym filter is usable as a search_analyzer. + +Calling the `_reload_search_analyzers` endpoint will now trigger reloading the +synonyms from the configured "synonym.txt" file. + +[source,js] +-------------------------------------------------- +POST /test_index/_reload_search_analyzers +-------------------------------------------------- +// CONSOLE From 8a3cc0afcf5bc5e0d23ce8809477b62dabcf1dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Wed, 5 Jun 2019 15:12:04 +0200 Subject: [PATCH 02/10] Adding the experimental warning and two additional note sections --- .../analysis/tokenfilters/synonym-tokenfilter.asciidoc | 5 +++-- docs/reference/indices/reload-analyzers.asciidoc | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc index 8ffd41267a696..b5333bea7c14f 100644 --- a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc @@ -220,5 +220,6 @@ PUT /test_index Using the <>, you can trigger reloading of the synonym definition. The contents of the configured synonyms file will be reloaded and the -synonyms definition the filter uses will be updated. Note that if you trying to use the above -analyzer as an index analyzer will result in an error. \ No newline at end of file +synonyms definition the filter uses will be updated. + +Note: Trying to use the above analyzer as an index analyzer will result in an error. \ No newline at end of file diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc index ffdd5530d460b..8138d3b377df8 100644 --- a/docs/reference/indices/reload-analyzers.asciidoc +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -1,6 +1,8 @@ [[indices-reload-analyzers]] == Reload Search Analyzers +experimental[] + Reloads search analyzers and its resources. The `_reload_search_analyzers` API can be run on one more indices and will @@ -49,6 +51,11 @@ PUT /test_index Calling the `_reload_search_analyzers` endpoint will now trigger reloading the synonyms from the configured "synonym.txt" file. +NOTE: Reloading will happen on every node the index has shards, so its important +to update the synonym file contents on every data node (even the ones that don't currently +hold shard copies; shards might be relocated there in the future) before calling +reload to ensure the new state of the file is reflected everywhere in the cluster. + [source,js] -------------------------------------------------- POST /test_index/_reload_search_analyzers From e65ae206510c905ddf24f4da76045f14af30a329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Thu, 6 Jun 2019 11:12:29 +0200 Subject: [PATCH 03/10] Include api doc in index page and fix links --- .../analysis/tokenfilters/synonym-tokenfilter.asciidoc | 8 ++++---- docs/reference/indices.asciidoc | 3 +++ docs/reference/indices/reload-analyzers.asciidoc | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc index b5333bea7c14f..abb58b8ff22be 100644 --- a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc @@ -44,8 +44,8 @@ Additional settings are: * `lenient` (defaults to `false`). If `true` ignores exceptions while parsing the synonym configuration. It is important to note that only those synonym rules which cannot get parsed are ignored. For instance consider the following request: * `updateable` (defaults to false). If `true`, this marks the filter to be updateable using the -<>, but it will also restrict the filter to only be usable in -<>. +<>, but it will also restrict the filter to only be usable in +<>. [source,js] @@ -188,7 +188,7 @@ with the multi-token filters in one branch and the synonym filter in the other. === Updateability of search time synonyms -Synonym filters that are used in <> can be marked +Synonym filters that are used in <> can be marked as updateable using the `updateable` flag: [source,js] @@ -218,7 +218,7 @@ PUT /test_index -------------------------------------------------- // CONSOLE -Using the <>, you can trigger reloading of the +Using the <>, you can trigger reloading of the synonym definition. The contents of the configured synonyms file will be reloaded and the synonyms definition the filter uses will be updated. diff --git a/docs/reference/indices.asciidoc b/docs/reference/indices.asciidoc index cda7c41cb42d1..564fb8c1e62bc 100644 --- a/docs/reference/indices.asciidoc +++ b/docs/reference/indices.asciidoc @@ -56,6 +56,7 @@ index settings, aliases, mappings, and index templates. * <> * <> * <> +* <> -- @@ -109,3 +110,5 @@ include::indices/refresh.asciidoc[] include::indices/forcemerge.asciidoc[] +include::indices/reload-analyzers.asciidoc[] + diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc index 8138d3b377df8..7d3cf7518c1d5 100644 --- a/docs/reference/indices/reload-analyzers.asciidoc +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -8,7 +8,7 @@ Reloads search analyzers and its resources. The `_reload_search_analyzers` API can be run on one more indices and will reload all search analyzers that contain components that were marked as updateable when they were created, such as -<>: +<>: [source,js] -------------------------------------------------- From dbab4caf6b0d89fc15837467f17459f365946c96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Tue, 11 Jun 2019 15:42:46 +0200 Subject: [PATCH 04/10] iter --- docs/reference/indices/reload-analyzers.asciidoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc index 7d3cf7518c1d5..ad27325bd15f7 100644 --- a/docs/reference/indices/reload-analyzers.asciidoc +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -18,7 +18,7 @@ PUT /test_index "index" : { "analysis" : { "analyzer" : { - "synonym" : { + "my_synonyms" : { "tokenizer" : "whitespace", "filter" : ["synonym"] } @@ -37,7 +37,8 @@ PUT /test_index "properties": { "text": { "type": "text", - "search_analyzer": "synonym" <2> + "analyzer" : "standard", + "search_analyzer": "my_synonyms" <2> } } } @@ -46,7 +47,7 @@ PUT /test_index // CONSOLE <1> Mark the synonym filter as updateable. -<2> Synonym filter is usable as a search_analyzer. +<2> Synonym analyzer is usable as a search_analyzer. Calling the `_reload_search_analyzers` endpoint will now trigger reloading the synonyms from the configured "synonym.txt" file. From 5c1699c2ea1cdfe3e2e299033bef9f494ffc59c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 14 Jun 2019 18:11:32 +0200 Subject: [PATCH 05/10] Add new endpoint rest-api-spec --- .../api/indices.reload_search_analyzers.json | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json new file mode 100644 index 0000000000000..478e195c510f2 --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json @@ -0,0 +1,32 @@ +{ + "rank_eval": { + "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html", + "methods": ["GET", "POST"], + "url": { + "paths": ["/{index}/_reload_search_analyzers"], + "parts": { + "index": { + "type": "list", + "description" : "A comma-separated list of index names to reload analyzers for" + } + }, + "params": { + "ignore_unavailable": { + "type" : "boolean", + "description" : "Whether specified concrete indices should be ignored when unavailable (missing or closed)" + }, + "allow_no_indices": { + "type" : "boolean", + "description" : "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)" + }, + "expand_wildcards": { + "type" : "enum", + "options" : ["open","closed","none","all"], + "default" : "open", + "description" : "Whether to expand wildcard expression to concrete indices that are open, closed or both." + } + } + }, + "body": null + } +} From e578689cb685a0d966aa0fb11cc0fdba31fa8a45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Fri, 14 Jun 2019 18:40:07 +0200 Subject: [PATCH 06/10] iter --- .../rest-api-spec/api/indices.reload_search_analyzers.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json index 478e195c510f2..dd649f5ad98ab 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json @@ -1,5 +1,5 @@ { - "rank_eval": { + "indices.reload_search_analyzers": { "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html", "methods": ["GET", "POST"], "url": { From 016aa32a1917df3a62015d100b74d521962fc135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Sun, 16 Jun 2019 12:21:58 +0200 Subject: [PATCH 07/10] iter --- .../org/elasticsearch/client/RestHighLevelClientTests.java | 3 ++- docs/reference/indices/reload-analyzers.asciidoc | 3 ++- .../src/main/java/org/elasticsearch/action/ActionModule.java | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java index ed5d7b66d80c1..d87ec8936fa88 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RestHighLevelClientTests.java @@ -711,7 +711,8 @@ public void testApiNamingConventions() throws Exception { "indices.get_upgrade", "indices.put_alias", "render_search_template", - "scripts_painless_execute" + "scripts_painless_execute", + "indices.reload_search_analyzers" }; //These API are not required for high-level client feature completeness String[] notRequiredApi = new String[] { diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc index ad27325bd15f7..3b1085f0d1480 100644 --- a/docs/reference/indices/reload-analyzers.asciidoc +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -59,6 +59,7 @@ reload to ensure the new state of the file is reflected everywhere in the cluste [source,js] -------------------------------------------------- -POST /test_index/_reload_search_analyzers +POST /my_index/_reload_search_analyzers -------------------------------------------------- // CONSOLE +// TEST[s/^/PUT my_index\n/] \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/action/ActionModule.java b/server/src/main/java/org/elasticsearch/action/ActionModule.java index 96232f404a657..a50bfe84fce6d 100644 --- a/server/src/main/java/org/elasticsearch/action/ActionModule.java +++ b/server/src/main/java/org/elasticsearch/action/ActionModule.java @@ -283,6 +283,7 @@ import org.elasticsearch.rest.action.admin.indices.RestPutMappingAction; import org.elasticsearch.rest.action.admin.indices.RestRecoveryAction; import org.elasticsearch.rest.action.admin.indices.RestRefreshAction; +import org.elasticsearch.rest.action.admin.indices.RestReloadAnalyzersAction; import org.elasticsearch.rest.action.admin.indices.RestResizeHandler; import org.elasticsearch.rest.action.admin.indices.RestRolloverIndexAction; import org.elasticsearch.rest.action.admin.indices.RestSyncedFlushAction; @@ -608,6 +609,7 @@ public void initRestHandlers(Supplier nodesInCluster) { registerHandler.accept(new RestGetFieldMappingAction(settings, restController)); registerHandler.accept(new RestRefreshAction(settings, restController)); + registerHandler.accept(new RestReloadAnalyzersAction(settings, restController)); registerHandler.accept(new RestFlushAction(settings, restController)); registerHandler.accept(new RestSyncedFlushAction(settings, restController)); registerHandler.accept(new RestForceMergeAction(settings, restController)); From 6ee56473aef709a99ab60f6f1bdd3f6f6f381fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Sun, 16 Jun 2019 14:49:08 +0200 Subject: [PATCH 08/10] adding rest-api stability --- .../rest-api-spec/api/indices.reload_search_analyzers.json | 1 + 1 file changed, 1 insertion(+) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json index dd649f5ad98ab..bd79dbf4718f5 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/indices.reload_search_analyzers.json @@ -1,6 +1,7 @@ { "indices.reload_search_analyzers": { "documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-reload-analyzers.html", + "stability": "experimental", "methods": ["GET", "POST"], "url": { "paths": ["/{index}/_reload_search_analyzers"], From 459cb6ce069d3ee30a4fa9ca71e6cd7828fbd614 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Sun, 16 Jun 2019 20:28:22 +0200 Subject: [PATCH 09/10] Change order of parameters --- .../analysis/tokenfilters/synonym-tokenfilter.asciidoc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc index abb58b8ff22be..e6704200818f5 100644 --- a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc @@ -41,11 +41,12 @@ appear before it in the chain. Additional settings are: * `expand` (defaults to `true`). -* `lenient` (defaults to `false`). If `true` ignores exceptions while parsing the synonym configuration. It is important -to note that only those synonym rules which cannot get parsed are ignored. For instance consider the following request: * `updateable` (defaults to false). If `true`, this marks the filter to be updateable using the <>, but it will also restrict the filter to only be usable in -<>. +<>. +* `lenient` (defaults to `false`). If `true` ignores exceptions while parsing the synonym configuration. It is important +to note that only those synonym rules which cannot get parsed are ignored. For instance consider the following request: + [source,js] From c59cca7aaf5c3aecbe6f73959c8d5d0a331cc3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Mon, 17 Jun 2019 13:05:50 +0200 Subject: [PATCH 10/10] Addressing comments --- .../analysis/tokenfilters/synonym-tokenfilter.asciidoc | 2 +- docs/reference/indices/reload-analyzers.asciidoc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc index e6704200818f5..089332dbb9617 100644 --- a/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc +++ b/docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc @@ -223,4 +223,4 @@ Using the <>, you can trigger relo synonym definition. The contents of the configured synonyms file will be reloaded and the synonyms definition the filter uses will be updated. -Note: Trying to use the above analyzer as an index analyzer will result in an error. \ No newline at end of file +NOTE: Trying to use the above analyzer as an index analyzer will result in an error. \ No newline at end of file diff --git a/docs/reference/indices/reload-analyzers.asciidoc b/docs/reference/indices/reload-analyzers.asciidoc index 3b1085f0d1480..5eb245b2aaea0 100644 --- a/docs/reference/indices/reload-analyzers.asciidoc +++ b/docs/reference/indices/reload-analyzers.asciidoc @@ -5,7 +5,7 @@ experimental[] Reloads search analyzers and its resources. -The `_reload_search_analyzers` API can be run on one more indices and will +The `_reload_search_analyzers` API can be run on one or more indices and will reload all search analyzers that contain components that were marked as updateable when they were created, such as <>: @@ -49,7 +49,7 @@ PUT /test_index <1> Mark the synonym filter as updateable. <2> Synonym analyzer is usable as a search_analyzer. -Calling the `_reload_search_analyzers` endpoint will now trigger reloading the +Calling the `_reload_search_analyzers` endpoint will now trigger reloading of the synonyms from the configured "synonym.txt" file. NOTE: Reloading will happen on every node the index has shards, so its important