-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow reloading of search time analyzers (#43313)
Currently changing resources (like dictionaries, synonym files etc...) of search time analyzers is only possible by closing an index, changing the underlying resource (e.g. synonym files) and then re-opening the index for the change to take effect. This PR adds a new API endpoint that allows triggering reloading of certain analysis resources (currently token filters) that will then pick up changes in underlying file resources. To achieve this we introduce a new type of custom analyzer (ReloadableCustomAnalyzer) that uses a ReuseStrategy that allows swapping out analysis components. Custom analyzers that contain filters that are markes as "updateable" will automatically choose this implementation. This PR also adds this capability to `synonym` token filters for use in search time analyzers. Relates to #29051
- Loading branch information
Christoph Büscher
authored
Jun 27, 2019
1 parent
29f5c2d
commit 56ee1a5
Showing
38 changed files
with
1,454 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
[role="xpack"] | ||
[testenv="basic"] | ||
[[indices-reload-analyzers]] | ||
== Reload Search Analyzers | ||
|
||
experimental[] | ||
|
||
Reloads search analyzers and its resources. | ||
|
||
Synonym filters (both `synonym` and `synonym_graph`) can be declared as | ||
updateable if they are only used in <<search-analyzer,search analyzers>> | ||
with the `updateable` flag: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /my_index | ||
{ | ||
"settings": { | ||
"index" : { | ||
"analysis" : { | ||
"analyzer" : { | ||
"my_synonyms" : { | ||
"tokenizer" : "whitespace", | ||
"filter" : ["synonym"] | ||
} | ||
}, | ||
"filter" : { | ||
"synonym" : { | ||
"type" : "synonym", | ||
"synonyms_path" : "analysis/synonym.txt", | ||
"updateable" : true <1> | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"mappings": { | ||
"properties": { | ||
"text": { | ||
"type": "text", | ||
"analyzer" : "standard", | ||
"search_analyzer": "my_synonyms" <2> | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
|
||
<1> Mark the synonym filter as updateable. | ||
<2> Synonym analyzer is usable as a search_analyzer. | ||
|
||
NOTE: Trying to use the above analyzer as an index analyzer will result in an error. | ||
|
||
Using the <<indices-reload-analyzers,analyzer reload API>>, 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. | ||
|
||
The `_reload_search_analyzers` API can be run on one or more indices and will trigger | ||
reloading of the synonyms from the configured 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 /my_index/_reload_search_analyzers | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[s/^/PUT my_index\n/] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.