reload-analyzers.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[indices-reload-analyzers]]
  4. == Reload search analyzers API
  5. ++++
  6. <titleabbrev>Reload search analyzers</titleabbrev>
  7. ++++
  8. Reloads an index's <<search-analyzer,search analyzers>> and their resources.
  9. For data streams, the API reloads search analyzers and resources for the
  10. stream's backing indices.
  11. [source,console]
  12. --------------------------------------------------
  13. POST /my-index-000001/_reload_search_analyzers
  14. --------------------------------------------------
  15. // TEST[setup:my_index]
  16. [discrete]
  17. [[indices-reload-analyzers-api-request]]
  18. === {api-request-title}
  19. `POST /<target>/_reload_search_analyzers`
  20. `GET /<target>/_reload_search_analyzers`
  21. [discrete]
  22. [[indices-reload-analyzers-api-desc]]
  23. === {api-description-title}
  24. You can use the reload search analyzers API
  25. to pick up changes to synonym files
  26. used in the <<analysis-synonym-graph-tokenfilter,`synonym_graph`>>
  27. or <<analysis-synonym-tokenfilter,`synonym`>> token filter
  28. of a <<search-analyzer,search analyzer>>.
  29. To be eligible,
  30. the token filter must have an `updateable` flag of `true`
  31. and only be used in search analyzers.
  32. [NOTE]
  33. ====
  34. This API does not perform a reload
  35. for each shard of an index.
  36. Instead,
  37. it performs a reload for each node
  38. containing index shards.
  39. As a result,
  40. the total shard count returned by the API
  41. can differ from the number of index shards.
  42. Because reloading affects every node with an index shard,
  43. its important to update the synonym file
  44. on every data node in the cluster,
  45. including nodes that don't contain a shard replica,
  46. before using this API.
  47. This ensures the synonym file is updated
  48. everywhere in the cluster
  49. in case shards are relocated
  50. in the future.
  51. ====
  52. [discrete]
  53. [[indices-reload-analyzers-api-path-params]]
  54. === {api-path-parms-title}
  55. `<target>`::
  56. (Required, string)
  57. Comma-separated list of data streams, indices, and index aliases used to limit
  58. the request. Wildcard expressions (`*`) are supported.
  59. +
  60. To target all data streams and indices in a cluster, use `_all` or `*`.
  61. [discrete]
  62. [[indices-reload-analyzers-api-query-params]]
  63. === {api-query-parms-title}
  64. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  65. +
  66. Defaults to `true`.
  67. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  68. +
  69. Defaults to `open`.
  70. include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  71. [discrete]
  72. [[indices-reload-analyzers-api-example]]
  73. === {api-examples-title}
  74. Use the <<indices-create-index, create index API>>
  75. to create an index with a search analyzer
  76. that contains an updateable synonym filter.
  77. NOTE: Using the following analyzer as an index analyzer results in an error.
  78. [source,console]
  79. --------------------------------------------------
  80. PUT /my-index-000001
  81. {
  82. "settings": {
  83. "index": {
  84. "analysis": {
  85. "analyzer": {
  86. "my_synonyms": {
  87. "tokenizer": "whitespace",
  88. "filter": [ "synonym" ]
  89. }
  90. },
  91. "filter": {
  92. "synonym": {
  93. "type": "synonym_graph",
  94. "synonyms_path": "analysis/synonym.txt", <1>
  95. "updateable": true <2>
  96. }
  97. }
  98. }
  99. }
  100. },
  101. "mappings": {
  102. "properties": {
  103. "text": {
  104. "type": "text",
  105. "analyzer": "standard",
  106. "search_analyzer": "my_synonyms" <3>
  107. }
  108. }
  109. }
  110. }
  111. --------------------------------------------------
  112. <1> Includes a synonym file.
  113. <2> Marks the token filter as updateable.
  114. <3> Marks the analyzer as a search analyzer.
  115. After updating the synonym file,
  116. use the <<indices-reload-analyzers,analyzer reload API>>
  117. to reload the search analyzer
  118. and pick up the file changes.
  119. [source,console]
  120. --------------------------------------------------
  121. POST /my-index-000001/_reload_search_analyzers
  122. --------------------------------------------------
  123. // TEST[continued]
  124. The API returns the following response.
  125. [source,console-result]
  126. --------------------------------------------------
  127. {
  128. "_shards": {
  129. "total": 2,
  130. "successful": 2,
  131. "failed": 0
  132. },
  133. "reload_details": [
  134. {
  135. "index": "my-index-000001",
  136. "reloaded_analyzers": [
  137. "my_synonyms"
  138. ],
  139. "reloaded_node_ids": [
  140. "mfdqTXn_T7SGr2Ho2KT8uw"
  141. ]
  142. }
  143. ]
  144. }
  145. --------------------------------------------------
  146. // TEST[continued]
  147. // TESTRESPONSE[s/"total": 2/"total": $body._shards.total/]
  148. // TESTRESPONSE[s/"successful": 2/"successful": $body._shards.successful/]
  149. // TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]