2019-06-28 03:55:40 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
|
|
|
[[indices-reload-analyzers]]
|
2019-10-11 09:40:49 -04:00
|
|
|
== Reload search analyzers API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Reload search analyzers</titleabbrev>
|
|
|
|
++++
|
2019-06-28 03:55:40 -04:00
|
|
|
|
2019-10-11 09:40:49 -04:00
|
|
|
Reloads an index's <<search-analyzer,search analyzers>> and their resources.
|
2020-07-13 12:50:47 -04:00
|
|
|
For data streams, the API reloads search analyzers and resources for the
|
|
|
|
stream's backing indices.
|
2019-06-28 03:55:40 -04:00
|
|
|
|
2019-10-11 09:40:49 -04:00
|
|
|
[source,console]
|
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
POST /my-index-000001/_reload_search_analyzers
|
2019-10-11 09:40:49 -04:00
|
|
|
--------------------------------------------------
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|
2019-10-11 09:40:49 -04:00
|
|
|
|
|
|
|
[discrete]
|
|
|
|
[[indices-reload-analyzers-api-request]]
|
|
|
|
=== {api-request-title}
|
|
|
|
|
2020-07-13 12:50:47 -04:00
|
|
|
`POST /<target>/_reload_search_analyzers`
|
2019-10-11 09:40:49 -04:00
|
|
|
|
2020-07-13 12:50:47 -04:00
|
|
|
`GET /<target>/_reload_search_analyzers`
|
2019-10-11 09:40:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
[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 <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
|
|
|
|
or <<analysis-synonym-tokenfilter,`synonym`>> token filter
|
|
|
|
of a <<search-analyzer,search analyzer>>.
|
|
|
|
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}
|
|
|
|
|
2020-07-13 12:50:47 -04:00
|
|
|
`<target>`::
|
2019-10-11 09:40:49 -04:00
|
|
|
(Required, string)
|
2020-07-13 12:50:47 -04:00
|
|
|
Comma-separated list of data streams, indices, and index aliases used to limit
|
|
|
|
the request. Wildcard expressions (`*`) are supported.
|
|
|
|
+
|
|
|
|
To target all data streams and indices in a cluster, use `_all` or `*`.
|
2019-10-11 09:40:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
[discrete]
|
|
|
|
[[indices-reload-analyzers-api-query-params]]
|
|
|
|
=== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-10-11 09:40:49 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-10-11 09:40:49 -04:00
|
|
|
+
|
|
|
|
Defaults to `open`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-10-11 09:40:49 -04:00
|
|
|
|
|
|
|
|
|
|
|
[discrete]
|
|
|
|
[[indices-reload-analyzers-api-example]]
|
|
|
|
=== {api-examples-title}
|
|
|
|
|
|
|
|
Use the <<indices-create-index, create index API>>
|
|
|
|
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.
|
2019-06-28 03:55:40 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-06-28 03:55:40 -04:00
|
|
|
--------------------------------------------------
|
2020-07-27 15:58:26 -04:00
|
|
|
PUT /my-index-000001
|
2019-06-28 03:55:40 -04:00
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"settings": {
|
|
|
|
"index": {
|
|
|
|
"analysis": {
|
|
|
|
"analyzer": {
|
|
|
|
"my_synonyms": {
|
|
|
|
"tokenizer": "whitespace",
|
|
|
|
"filter": [ "synonym" ]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"filter": {
|
|
|
|
"synonym": {
|
|
|
|
"type": "synonym_graph",
|
|
|
|
"synonyms_path": "analysis/synonym.txt", <1>
|
|
|
|
"updateable": true <2>
|
|
|
|
}
|
2019-06-28 03:55:40 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"mappings": {
|
|
|
|
"properties": {
|
|
|
|
"text": {
|
|
|
|
"type": "text",
|
|
|
|
"analyzer": "standard",
|
|
|
|
"search_analyzer": "my_synonyms" <3>
|
|
|
|
}
|
2019-06-28 03:55:40 -04:00
|
|
|
}
|
2020-07-21 15:49:58 -04:00
|
|
|
}
|
2019-06-28 03:55:40 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
2019-10-11 09:40:49 -04:00
|
|
|
<1> Includes a synonym file.
|
|
|
|
<2> Marks the token filter as updateable.
|
|
|
|
<3> Marks the analyzer as a search analyzer.
|
2019-06-28 03:55:40 -04:00
|
|
|
|
2019-10-11 09:40:49 -04:00
|
|
|
After updating the synonym file,
|
|
|
|
use the <<indices-reload-analyzers,analyzer reload API>>
|
|
|
|
to reload the search analyzer
|
|
|
|
and pick up the file changes.
|
2019-06-28 03:55:40 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-06-28 03:55:40 -04:00
|
|
|
--------------------------------------------------
|
2020-07-27 15:58:26 -04:00
|
|
|
POST /my-index-000001/_reload_search_analyzers
|
2019-06-28 03:55:40 -04:00
|
|
|
--------------------------------------------------
|
2019-07-02 12:08:04 -04:00
|
|
|
// TEST[continued]
|
|
|
|
|
2019-10-11 09:40:49 -04:00
|
|
|
The API returns the following response.
|
2019-07-02 12:08:04 -04:00
|
|
|
|
2019-09-06 16:09:09 -04:00
|
|
|
[source,console-result]
|
2019-07-02 12:08:04 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
"_shards": {
|
|
|
|
"total": 2,
|
|
|
|
"successful": 2,
|
|
|
|
"failed": 0
|
|
|
|
},
|
|
|
|
"reload_details": [
|
|
|
|
{
|
2020-07-27 15:58:26 -04:00
|
|
|
"index": "my-index-000001",
|
2020-07-21 15:49:58 -04:00
|
|
|
"reloaded_analyzers": [
|
|
|
|
"my_synonyms"
|
|
|
|
],
|
|
|
|
"reloaded_node_ids": [
|
|
|
|
"mfdqTXn_T7SGr2Ho2KT8uw"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2019-07-02 12:08:04 -04:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
2020-07-21 15:49:58 -04:00
|
|
|
// TESTRESPONSE[s/"total": 2/"total": $body._shards.total/]
|
|
|
|
// TESTRESPONSE[s/"successful": 2/"successful": $body._shards.successful/]
|
2019-07-02 12:08:04 -04:00
|
|
|
// TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
|