reload-analyzers.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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,js]
  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. // CONSOLE
  45. <1> Mark the synonym filter as updateable.
  46. <2> Synonym analyzer is usable as a search_analyzer.
  47. NOTE: Trying to use the above analyzer as an index analyzer will result in an error.
  48. Using the <<indices-reload-analyzers,analyzer reload API>>, you can trigger reloading of the
  49. synonym definition. The contents of the configured synonyms file will be reloaded and the
  50. synonyms definition the filter uses will be updated.
  51. The `_reload_search_analyzers` API can be run on one or more indices and will trigger
  52. reloading of the synonyms from the configured file.
  53. NOTE: Reloading will happen on every node the index has shards, so its important
  54. to update the synonym file contents on every data node (even the ones that don't currently
  55. hold shard copies; shards might be relocated there in the future) before calling
  56. reload to ensure the new state of the file is reflected everywhere in the cluster.
  57. [source,js]
  58. --------------------------------------------------
  59. POST /my_index/_reload_search_analyzers
  60. --------------------------------------------------
  61. // CONSOLE
  62. // TEST[continued]
  63. The reload request returns information about the nodes it was executed on and the
  64. analyzers that were reloaded:
  65. [source,js]
  66. --------------------------------------------------
  67. {
  68. "_shards" : {
  69. "total" : 2,
  70. "successful" : 2,
  71. "failed" : 0
  72. },
  73. "reload_details" : [
  74. {
  75. "index" : "my_index",
  76. "reloaded_analyzers" : [
  77. "my_synonyms"
  78. ],
  79. "reloaded_node_ids" : [
  80. "mfdqTXn_T7SGr2Ho2KT8uw"
  81. ]
  82. }
  83. ]
  84. }
  85. --------------------------------------------------
  86. // TEST[continued]
  87. // TESTRESPONSE[s/"total" : 2/"total" : $body._shards.total/]
  88. // TESTRESPONSE[s/"successful" : 2/"successful" : $body._shards.successful/]
  89. // TESTRESPONSE[s/mfdqTXn_T7SGr2Ho2KT8uw/$body.reload_details.0.reloaded_node_ids.0/]
  90. NOTE: Reloading does not happen on each shard of an index, but once on each node
  91. the index has shards on. The total shard count can therefore differ from the number
  92. of index shards.