reload-analyzers.asciidoc 4.5 KB

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