Skip to content
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.
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]]
== Reload Search Analyzers

Reloads search analyzers and its resources.

The `_reload_search_analyzers` API can be run on one more indices and will
Copy link
Contributor

Choose a reason for hiding this comment

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

nit:/can be run on one more/can be run on one or more/

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

Choose a reason for hiding this comment

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

nit:s/reloading the/reloading of the/ ?

synonyms from the configured "synonym.txt" file.

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