11[role="xpack"]
22[testenv="basic"]
33[[indices-reload-analyzers]]
4- == Reload Search Analyzers
4+ == Reload search analyzers API
5+ ++++
6+ <titleabbrev>Reload search analyzers</titleabbrev>
7+ ++++
58
6- experimental[]
9+ experimental:: []
710
8- Reloads search analyzers and its resources.
11+ Reloads an index's << search-analyzer,search analyzers>> and their resources.
912
10- Synonym filters (both `synonym` and `synonym_graph`) can be declared as
11- updateable if they are only used in <<search-analyzer,search analyzers>>
12- with the `updateable` flag:
13+ [source,js]
14+ --------------------------------------------------
15+ POST /twitter/_reload_search_analyzers
16+ --------------------------------------------------
17+ // CONSOLE
18+ // TEST[setup:twitter]
19+
20+ [discrete]
21+ [[indices-reload-analyzers-api-request]]
22+ === {api-request-title}
23+
24+ `POST /<index>/_reload_search_analyzers`
25+
26+ `GET /<index>/_reload_search_analyzers`
27+
28+
29+ [discrete]
30+ [[indices-reload-analyzers-api-desc]]
31+ === {api-description-title}
32+
33+ You can use the reload search analyzers API
34+ to pick up changes to synonym files
35+ used in the <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
36+ or <<analysis-synonym-tokenfilter,`synonym`>> token filter
37+ of a <<search-analyzer,search analyzer>>.
38+ To be eligible,
39+ the token filter must have an `updateable` flag of `true`
40+ and only be used in search analyzers.
41+
42+ [NOTE]
43+ ====
44+ This API does not perform a reload
45+ for each shard of an index.
46+ Instead,
47+ it performs a reload for each node
48+ containing index shards.
49+ As a result,
50+ the total shard count returned by the API
51+ can differ from the number of index shards.
52+
53+ Because reloading affects every node with an index shard,
54+ its important to update the synonym file
55+ on every data node in the cluster,
56+ including nodes that don't contain a shard replica,
57+ before using this API.
58+ This ensures the synonym file is updated
59+ everywhere in the cluster
60+ in case shards are relocated
61+ in the future.
62+ ====
63+
64+
65+ [discrete]
66+ [[indices-reload-analyzers-api-path-params]]
67+ === {api-path-parms-title}
68+
69+ `<index>`::
70+ (Required, string)
71+ Comma-separated list or wildcard expression of index names
72+ used to limit the request.
73+
74+
75+ [discrete]
76+ [[indices-reload-analyzers-api-query-params]]
77+ === {api-query-parms-title}
78+
79+ include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
80+
81+ include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
82+ +
83+ Defaults to `open`.
84+
85+ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
86+
87+
88+ [discrete]
89+ [[indices-reload-analyzers-api-example]]
90+ === {api-examples-title}
91+
92+ Use the <<indices-create-index, create index API>>
93+ to create an index with a search analyzer
94+ that contains an updateable synonym filter.
95+
96+ NOTE: Using the following analyzer as an index analyzer results in an error.
1397
1498[source,js]
1599--------------------------------------------------
@@ -26,9 +110,9 @@ PUT /my_index
26110 },
27111 "filter" : {
28112 "synonym" : {
29- "type" : "synonym ",
30- "synonyms_path" : "analysis/synonym.txt",
31- "updateable" : true <1 >
113+ "type" : "synonym_graph ",
114+ "synonyms_path" : "analysis/synonym.txt", <1>
115+ "updateable" : true <2 >
32116 }
33117 }
34118 }
@@ -39,30 +123,22 @@ PUT /my_index
39123 "text": {
40124 "type": "text",
41125 "analyzer" : "standard",
42- "search_analyzer": "my_synonyms" <2 >
126+ "search_analyzer": "my_synonyms" <3 >
43127 }
44128 }
45129 }
46130}
47131--------------------------------------------------
48132// CONSOLE
49133
50- <1> Mark the synonym filter as updateable.
51- <2> Synonym analyzer is usable as a search_analyzer.
52-
53- NOTE: Trying to use the above analyzer as an index analyzer will result in an error.
134+ <1> Includes a synonym file.
135+ <2> Marks the token filter as updateable.
136+ <3> Marks the analyzer as a search analyzer.
54137
55- Using the <<indices-reload-analyzers,analyzer reload API>>, you can trigger reloading of the
56- synonym definition. The contents of the configured synonyms file will be reloaded and the
57- synonyms definition the filter uses will be updated.
58-
59- The `_reload_search_analyzers` API can be run on one or more indices and will trigger
60- reloading of the synonyms from the configured file.
61-
62- NOTE: Reloading will happen on every node the index has shards, so its important
63- to update the synonym file contents on every data node (even the ones that don't currently
64- hold shard copies; shards might be relocated there in the future) before calling
65- reload to ensure the new state of the file is reflected everywhere in the cluster.
138+ After updating the synonym file,
139+ use the <<indices-reload-analyzers,analyzer reload API>>
140+ to reload the search analyzer
141+ and pick up the file changes.
66142
67143[source,js]
68144--------------------------------------------------
@@ -71,8 +147,7 @@ POST /my_index/_reload_search_analyzers
71147// CONSOLE
72148// TEST[continued]
73149
74- The reload request returns information about the nodes it was executed on and the
75- analyzers that were reloaded:
150+ The API returns the following response.
76151
77152[source,js]
78153--------------------------------------------------
@@ -99,7 +174,3 @@ analyzers that were reloaded:
99174// TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/]
100175// TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/]
101176// TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
102-
103- NOTE: Reloading does not happen on each shard of an index, but once on each node
104- the index has shards on. The total shard count can therefore differ from the number
105- of index shards.
0 commit comments