Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions docs/reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
<<analyzer reload API,indices-reload-analyzers>>, but it will also restrict the filter to only be usable in
<<search analyzers,search-analyzer>>.


[source,js]
--------------------------------------------------
Expand Down Expand Up @@ -181,3 +185,40 @@ error.
If you need to build analyzers that include both multi-token filters and synonym
filters, consider using the <<analysis-multiplexer-tokenfilter,multiplexer>> 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 <<search analyzers,search-analyzer>> 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 <<analyzer reload API,indices-reload-analyzers>>, 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would extract the last sentence in a NOTE in order to make sure that users are aware of the limitation.

56 changes: 56 additions & 0 deletions docs/reference/indices/reload-analyzers.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[[indices-reload-analyzers]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be marked as experimental.

== 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
<<synonym token filters,analysis-synonym-tokenfilter>>:

[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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a NOTE regarding the fact that the reload is per node so you need to update your synonym.txt file on every node before calling reload.


[source,js]
--------------------------------------------------
POST /test_index/_reload_search_analyzers
--------------------------------------------------
// CONSOLE