reload-analyzers.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[indices-reload-analyzers]]
  4. == Reload Search Analyzers
  5. experimental[]
  6. Reloads search analyzers and its resources.
  7. Synonym filters (both `synonym` and `synonym_graph`) can be declared as
  8. updateable if they are only used in <<search-analyzer,search analyzers>>
  9. with the `updateable` flag:
  10. [source,console]
  11. --------------------------------------------------
  12. PUT /my_index
  13. {
  14. "settings": {
  15. "index" : {
  16. "analysis" : {
  17. "analyzer" : {
  18. "my_synonyms" : {
  19. "tokenizer" : "whitespace",
  20. "filter" : ["synonym"]
  21. }
  22. },
  23. "filter" : {
  24. "synonym" : {
  25. "type" : "synonym",
  26. "synonyms_path" : "analysis/synonym.txt",
  27. "updateable" : true <1>
  28. }
  29. }
  30. }
  31. }
  32. },
  33. "mappings": {
  34. "properties": {
  35. "text": {
  36. "type": "text",
  37. "analyzer" : "standard",
  38. "search_analyzer": "my_synonyms" <2>
  39. }
  40. }
  41. }
  42. }
  43. --------------------------------------------------
  44. <1> Mark the synonym filter as updateable.
  45. <2> Synonym analyzer is usable as a search_analyzer.
  46. NOTE: Trying to use the above analyzer as an index analyzer will result in an error.
  47. Using the <<indices-reload-analyzers,analyzer reload API>>, you can trigger reloading of the
  48. synonym definition. The contents of the configured synonyms file will be reloaded and the
  49. synonyms definition the filter uses will be updated.
  50. The `_reload_search_analyzers` API can be run on one or more indices and will trigger
  51. reloading of the synonyms from the configured file.
  52. NOTE: Reloading will happen on every node the index has shards, so its important
  53. to update the synonym file contents on every data node (even the ones that don't currently
  54. hold shard copies; shards might be relocated there in the future) before calling
  55. reload to ensure the new state of the file is reflected everywhere in the cluster.
  56. [source,console]
  57. --------------------------------------------------
  58. POST /my_index/_reload_search_analyzers
  59. --------------------------------------------------
  60. // TEST[continued]
  61. The reload request returns information about the nodes it was executed on and the
  62. analyzers that were reloaded:
  63. [source,console-result]
  64. --------------------------------------------------
  65. {
  66. "_shards" : {
  67. "total" : 2,
  68. "successful" : 2,
  69. "failed" : 0
  70. },
  71. "reload_details" : [
  72. {
  73. "index" : "my_index",
  74. "reloaded_analyzers" : [
  75. "my_synonyms"
  76. ],
  77. "reloaded_node_ids" : [
  78. "mfdqTXn_T7SGr2Ho2KT8uw"
  79. ]
  80. }
  81. ]
  82. }
  83. --------------------------------------------------
  84. // TEST[continued]
  85. // TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/]
  86. // TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/]
  87. // TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
  88. NOTE: Reloading does not happen on each shard of an index, but once on each node
  89. the index has shards on. The total shard count can therefore differ from the number
  90. of index shards.