suggest.asciidoc 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. [[breaking_50_suggester]]
  2. === Suggester changes
  3. The completion suggester has undergone a complete rewrite. This means that the
  4. syntax and data structure for fields of type `completion` have changed, as
  5. have the syntax and response of completion suggester requests.
  6. For indices created before Elasticsearch 5.0.0, `completion` fields and the
  7. completion suggester will continue to work as they did in Elasticsearch 2.x.
  8. However, it is not possible to run a completion suggester query across indices
  9. created in 2.x and indices created in 5.x.
  10. It is strongly recommended to reindex indices containing 2.x `completion`
  11. fields in 5.x to take advantage of the new features listed below.
  12. NOTE: You will need to change the structure of the completion field values
  13. when reindexing.
  14. ==== Completion suggester is near-real time
  15. Previously, deleted suggestions could be included in results even
  16. after refreshing an index. Now, deletions are visible in near-real
  17. time, i.e. as soon as the index has been refreshed. This applies
  18. to suggestion entries for both context and completion suggesters.
  19. ==== Completion suggester is document-oriented
  20. Suggestions are aware of the document they belong to. This enables
  21. retrieving any field value from the document. This is exposed
  22. through the query-time `payload` option in `completion` and `context`
  23. suggesters:
  24. [source,sh]
  25. ---------------
  26. GET /my_index/_search
  27. {
  28. "suggest": {
  29. "fooSuggestion": {
  30. "text": "f"
  31. "completion": {
  32. "field": "fooSuggest",
  33. "payload": ["field1", "field2"]
  34. }
  35. }
  36. }
  37. }
  38. ---------------
  39. Previously, `context` and `completion` suggesters supported an index-time
  40. `payloads` option, which was used to store and return metadata with suggestions.
  41. Now metadata can be stored as a field in the same document as the
  42. suggestion for enabling retrieval at query-time. The support for
  43. index-time `payloads` has been removed to avoid bloating the in-memory
  44. index with suggestion metadata. The time that it takes to retrieve payloads
  45. depends heavily on the size of the `_source` field. The smaller the `_source`,
  46. the faster the retrieval.
  47. ==== Simpler completion indexing
  48. As suggestions are document-oriented, suggestion metadata (e.g. `output`)
  49. should now be specified as a field in the document. The support for specifying
  50. `output` when indexing suggestion entries has been removed. Now suggestion
  51. result entry's `text` is always the un-analyzed value of the suggestion's
  52. `input` (same as not specifying `output` while indexing suggestions in pre-5.0
  53. indices).
  54. ==== Completion mapping with multiple contexts
  55. The `context` option in `completion` field mapping is now an array to support
  56. multiple named contexts per completion field. Note that this is sugar for
  57. indexing same suggestions under different name with different contexts.
  58. The `default` option for a named `context` has been removed. Now querying with
  59. no `context` against a context-enabled completion field yields results from all
  60. indexed suggestions. Note that performance for match-all-context query
  61. degrades with the number of unique context value for a given `completion` field.
  62. ==== Completion suggestion with multiple context filtering
  63. Previously `context` option in a suggest request was used for filtering suggestions
  64. by `context` value. Now, the option has been named to `contexts` to specify
  65. multiple named context filters. Note that this is not supported by pre-5.0 indices.
  66. Following is the `contexts` snippet for a suggest query filtered by both 'color'
  67. and 'location' contexts:
  68. [source,sh]
  69. ---------------
  70. "contexts": {
  71. "color": [ {...} ],
  72. "location": [ {...} ]
  73. }
  74. ---------------