[role="xpack"] [testenv="basic"] [[indices-reload-analyzers]] == Reload search analyzers API ++++ Reload search analyzers ++++ Reloads an index's <> and their resources. [source,console] -------------------------------------------------- POST /twitter/_reload_search_analyzers -------------------------------------------------- // TEST[setup:twitter] [discrete] [[indices-reload-analyzers-api-request]] === {api-request-title} `POST //_reload_search_analyzers` `GET //_reload_search_analyzers` [discrete] [[indices-reload-analyzers-api-desc]] === {api-description-title} You can use the reload search analyzers API to pick up changes to synonym files used in the <> or <> token filter of a <>. To be eligible, the token filter must have an `updateable` flag of `true` and only be used in search analyzers. [NOTE] ==== This API does not perform a reload for each shard of an index. Instead, it performs a reload for each node containing index shards. As a result, the total shard count returned by the API can differ from the number of index shards. Because reloading affects every node with an index shard, its important to update the synonym file on every data node in the cluster, including nodes that don't contain a shard replica, before using this API. This ensures the synonym file is updated everywhere in the cluster in case shards are relocated in the future. ==== [discrete] [[indices-reload-analyzers-api-path-params]] === {api-path-parms-title} ``:: (Required, string) Comma-separated list or wildcard expression of index names used to limit the request. [discrete] [[indices-reload-analyzers-api-query-params]] === {api-query-parms-title} include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices] + Defaults to `true`. include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards] + Defaults to `open`. include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable] [discrete] [[indices-reload-analyzers-api-example]] === {api-examples-title} Use the <> to create an index with a search analyzer that contains an updateable synonym filter. NOTE: Using the following analyzer as an index analyzer results in an error. [source,console] -------------------------------------------------- PUT /my_index { "settings": { "index" : { "analysis" : { "analyzer" : { "my_synonyms" : { "tokenizer" : "whitespace", "filter" : ["synonym"] } }, "filter" : { "synonym" : { "type" : "synonym_graph", "synonyms_path" : "analysis/synonym.txt", <1> "updateable" : true <2> } } } } }, "mappings": { "properties": { "text": { "type": "text", "analyzer" : "standard", "search_analyzer": "my_synonyms" <3> } } } } -------------------------------------------------- <1> Includes a synonym file. <2> Marks the token filter as updateable. <3> Marks the analyzer as a search analyzer. After updating the synonym file, use the <> to reload the search analyzer and pick up the file changes. [source,console] -------------------------------------------------- POST /my_index/_reload_search_analyzers -------------------------------------------------- // TEST[continued] The API returns the following response. [source,console-result] -------------------------------------------------- { "_shards" : { "total" : 2, "successful" : 2, "failed" : 0 }, "reload_details" : [ { "index" : "my_index", "reloaded_analyzers" : [ "my_synonyms" ], "reloaded_node_ids" : [ "mfdqTXn_T7SGr2Ho2KT8uw" ] } ] } -------------------------------------------------- // TEST[continued] // TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/] // TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/] // TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]