reload-analyzers.asciidoc 4.5 KB

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