percolator.asciidoc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [[breaking_50_percolator]]
  2. === Percolator changes
  3. ==== Percolator is near-real time
  4. Previously percolators were activated in real-time, i.e. as soon as they were
  5. indexed. Now, changes to the `percolate` query are visible in near-real time,
  6. as soon as the index has been refreshed. This change was required because, in
  7. indices created from 5.0 onwards, the terms used in a percolator query are
  8. automatically indexed to allow for more efficient query selection during
  9. percolation.
  10. ==== Percolate and multi percolator APIs
  11. Percolator and multi percolate APIs have been deprecated and will be removed in the next major release. These APIs have
  12. been replaced by the `percolate` query that can be used in the search and multi search APIs.
  13. ==== Percolator field mapping
  14. The `.percolator` type can no longer be used to index percolator queries.
  15. Instead a <<percolator,percolator field type>> must be configured prior to indexing percolator queries.
  16. Indices with a `.percolator` type created on a version before 5.0.0 can still be used,
  17. but new indices no longer accept the `.percolator` type.
  18. However it is strongly recommended to reindex any indices containing percolator queries created prior
  19. upgrading to Elasticsearch 5. By doing this the `percolate` query utilize the extracted terms the `percolator`
  20. field type extracted from the percolator queries and potentially execute many times faster.
  21. ==== Percolate document mapping
  22. The `percolate` query no longer modifies the mappings. Before the percolate API
  23. could be used to dynamically introduce new fields to the mappings based on the
  24. fields in the document being percolated. This no longer works, because these
  25. unmapped fields are not persisted in the mapping.
  26. ==== Percolator documents returned by search
  27. Documents with the `.percolate` type were previously excluded from the search
  28. response, unless the `.percolate` type was specified explicitly in the search
  29. request. Now, percolator documents are treated in the same way as any other
  30. document and are returned by search requests.
  31. ==== Percolating existing document
  32. When percolating an existing document then also specifying a document as source in the
  33. `percolate` query is not allowed any more. Before the percolate API allowed and ignored
  34. the existing document.
  35. ==== Percolate Stats
  36. The percolate stats have been removed. This is because the percolator no longer caches the percolator queries.
  37. ==== Percolator queries containing range queries with now ranges
  38. The percolator no longer accepts percolator queries containing `range` queries with ranges that are based on current
  39. time (using `now`).
  40. ==== Percolator queries containing scripts.
  41. Percolator queries that contain scripts (For example: `script` query or a `function_score` query script function) that
  42. have no explicit language specified will use the Painless scripting language from version 5.0 and up.
  43. Scripts with no explicit language set in percolator queries stored in indices created prior to version 5.0
  44. will use the language that has been configured in the `script.legacy.default_lang` setting. This setting defaults to
  45. the Groovy scripting language, which was the default for versions prior to 5.0. If your default scripting language was
  46. different then set the `script.legacy.default_lang` setting to the language you used before.
  47. In order to make use of the new `percolator` field type all percolator queries should be reindexed into a new index.
  48. When reindexing percolator queries with scripts that have no explicit language defined into a new index, one of the
  49. following two things should be done in order to make the scripts work:
  50. * (Recommended approach) While reindexing the percolator documents, migrate the scripts to the Painless scripting language.
  51. * or add `lang` parameter on the script and set it the language these scripts were written in.
  52. ==== Java client
  53. The percolator is no longer part of the core elasticsearch dependency. It has moved to the percolator module.
  54. Therefor when using the percolator feature from the Java client the new percolator module should also be on the
  55. classpath. Also the transport client should load the percolator module as plugin:
  56. [source,java]
  57. --------------------------------------------------
  58. TransportClient transportClient = TransportClient.builder()
  59. .settings(Settings.builder().put("node.name", "node"))
  60. .addPlugin(PercolatorPlugin.class)
  61. .build();
  62. transportClient.addTransportAddress(
  63. new InetSocketTransportAddress(new InetSocketAddress(InetAddresses.forString("127.0.0.1"), 9300))
  64. );
  65. --------------------------------------------------
  66. The percolator and multi percolate related methods from the `Client` interface have been removed. These APIs have been
  67. deprecated and it is recommended to use the `percolate` query in either the search or multi search APIs. However the
  68. percolate and multi percolate APIs can still be used from the Java client.
  69. Using percolate request:
  70. [source,java]
  71. --------------------------------------------------
  72. PercolateRequest request = new PercolateRequest();
  73. // set stuff and then execute:
  74. PercolateResponse response = transportClient.execute(PercolateAction.INSTANCE, request).actionGet();
  75. --------------------------------------------------
  76. Using percolate request builder:
  77. [source,java]
  78. --------------------------------------------------
  79. PercolateRequestBuilder builder = new PercolateRequestBuilder(transportClient, PercolateAction.INSTANCE);
  80. // set stuff and then execute:
  81. PercolateResponse response = builder.get();
  82. --------------------------------------------------
  83. Using multi percolate request:
  84. [source,java]
  85. --------------------------------------------------
  86. MultiPercolateRequest request = new MultiPercolateRequest();
  87. // set stuff and then execute:
  88. MultiPercolateResponse response = transportClient.execute(MultiPercolateAction.INSTANCE, request).get();
  89. --------------------------------------------------
  90. Using multi percolate request builder:
  91. [source,java]
  92. --------------------------------------------------
  93. MultiPercolateRequestBuilder builder = new MultiPercolateRequestBuilder(transportClient, MultiPercolateAction.INSTANCE);
  94. // set stuff and then execute:
  95. MultiPercolateResponse response = builder.get();
  96. --------------------------------------------------