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,console]
14+ --------------------------------------------------
15+ POST /twitter/_reload_search_analyzers
16+ --------------------------------------------------
17+ // TEST[setup:twitter]
18+
19+ [discrete]
20+ [[indices-reload-analyzers-api-request]]
21+ === {api-request-title}
22+
23+ `POST /<index>/_reload_search_analyzers`
24+
25+ `GET /<index>/_reload_search_analyzers`
26+
27+
28+ [discrete]
29+ [[indices-reload-analyzers-api-desc]]
30+ === {api-description-title}
31+
32+ You can use the reload search analyzers API
33+ to pick up changes to synonym files
34+ used in the <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
35+ or <<analysis-synonym-tokenfilter,`synonym`>> token filter
36+ of a <<search-analyzer,search analyzer>>.
37+ To be eligible,
38+ the token filter must have an `updateable` flag of `true`
39+ and only be used in search analyzers.
40+
41+ [NOTE]
42+ ====
43+ This API does not perform a reload
44+ for each shard of an index.
45+ Instead,
46+ it performs a reload for each node
47+ containing index shards.
48+ As a result,
49+ the total shard count returned by the API
50+ can differ from the number of index shards.
51+
52+ Because reloading affects every node with an index shard,
53+ its important to update the synonym file
54+ on every data node in the cluster,
55+ including nodes that don't contain a shard replica,
56+ before using this API.
57+ This ensures the synonym file is updated
58+ everywhere in the cluster
59+ in case shards are relocated
60+ in the future.
61+ ====
62+
63+
64+ [discrete]
65+ [[indices-reload-analyzers-api-path-params]]
66+ === {api-path-parms-title}
67+
68+ `<index>`::
69+ (Required, string)
70+ Comma-separated list or wildcard expression of index names
71+ used to limit the request.
72+
73+
74+ [discrete]
75+ [[indices-reload-analyzers-api-query-params]]
76+ === {api-query-parms-title}
77+
78+ include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
79+
80+ include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
81+ +
82+ Defaults to `open`.
83+
84+ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
85+
86+
87+ [discrete]
88+ [[indices-reload-analyzers-api-example]]
89+ === {api-examples-title}
90+
91+ Use the <<indices-create-index, create index API>>
92+ to create an index with a search analyzer
93+ that contains an updateable synonym filter.
94+
95+ NOTE: Using the following analyzer as an index analyzer results in an error.
1396
1497[source,console]
1598--------------------------------------------------
@@ -26,9 +109,9 @@ PUT /my_index
26109 },
27110 "filter" : {
28111 "synonym" : {
29- "type" : "synonym ",
30- "synonyms_path" : "analysis/synonym.txt",
31- "updateable" : true <1 >
112+ "type" : "synonym_graph ",
113+ "synonyms_path" : "analysis/synonym.txt", <1>
114+ "updateable" : true <2 >
32115 }
33116 }
34117 }
@@ -39,38 +122,29 @@ PUT /my_index
39122 "text": {
40123 "type": "text",
41124 "analyzer" : "standard",
42- "search_analyzer": "my_synonyms" <2 >
125+ "search_analyzer": "my_synonyms" <3 >
43126 }
44127 }
45128 }
46129}
47130--------------------------------------------------
48131
49- <1> Mark the synonym filter as updateable.
50- <2> Synonym analyzer is usable as a search_analyzer.
51-
52- NOTE: Trying to use the above analyzer as an index analyzer will result in an error.
132+ <1> Includes a synonym file.
133+ <2> Marks the token filter as updateable.
134+ <3> Marks the analyzer as a search analyzer.
53135
54- Using the <<indices-reload-analyzers,analyzer reload API>>, you can trigger reloading of the
55- synonym definition. The contents of the configured synonyms file will be reloaded and the
56- synonyms definition the filter uses will be updated.
57-
58- The `_reload_search_analyzers` API can be run on one or more indices and will trigger
59- reloading of the synonyms from the configured file.
60-
61- NOTE: Reloading will happen on every node the index has shards, so its important
62- to update the synonym file contents on every data node (even the ones that don't currently
63- hold shard copies; shards might be relocated there in the future) before calling
64- reload to ensure the new state of the file is reflected everywhere in the cluster.
136+ After updating the synonym file,
137+ use the <<indices-reload-analyzers,analyzer reload API>>
138+ to reload the search analyzer
139+ and pick up the file changes.
65140
66141[source,console]
67142--------------------------------------------------
68143POST /my_index/_reload_search_analyzers
69144--------------------------------------------------
70145// TEST[continued]
71146
72- The reload request returns information about the nodes it was executed on and the
73- analyzers that were reloaded:
147+ The API returns the following response.
74148
75149[source,console-result]
76150--------------------------------------------------
@@ -97,7 +171,3 @@ analyzers that were reloaded:
97171// TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/]
98172// TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/]
99173// TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
100-
101- NOTE: Reloading does not happen on each shard of an index, but once on each node
102- the index has shards on. The total shard count can therefore differ from the number
103- of index shards.
0 commit comments