terms-enum.asciidoc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. [[search-terms-enum]]
  2. === Terms enum API
  3. ++++
  4. <titleabbrev>Terms enum</titleabbrev>
  5. ++++
  6. The terms enum API can be used to discover terms in the index that match
  7. a partial string. Supported field types are <<keyword-field-type,`keyword`>>,
  8. <<constant-keyword-field-type,`constant_keyword`>>, <<flattened,`flattened`>>,
  9. <<version, `version`>> and <<ip, `ip`>>. This is used for auto-complete:
  10. [source,console]
  11. --------------------------------------------------
  12. POST stackoverflow/_terms_enum
  13. {
  14. "field" : "tags",
  15. "string" : "kiba"
  16. }
  17. --------------------------------------------------
  18. // TEST[setup:stackoverflow]
  19. The API returns the following response:
  20. [source,console-result]
  21. --------------------------------------------------
  22. {
  23. "_shards": {
  24. "total": 1,
  25. "successful": 1,
  26. "failed": 0
  27. },
  28. "terms": [
  29. "kibana"
  30. ],
  31. "complete" : true
  32. }
  33. --------------------------------------------------
  34. If the `complete` flag is `false`, the returned `terms` set may be incomplete
  35. and should be treated as approximate. This can occur due to a few reasons, such
  36. as a request timeout or a node error.
  37. NOTE: The terms enum API may return terms from deleted documents. Deleted
  38. documents are initially only marked as deleted. It is not until their segments
  39. are <<index-modules-merge,merged>> that documents are actually deleted. Until
  40. that happens, the terms enum API will return terms from these documents.
  41. [[search-terms-enum-api-request]]
  42. ==== {api-request-title}
  43. `GET /<target>/_terms_enum`
  44. [[search-terms-enum-api-desc]]
  45. ==== {api-description-title}
  46. The terms_enum API can be used to discover terms in the index that begin with the provided
  47. string. It is designed for low-latency look-ups used in auto-complete scenarios.
  48. [[search-terms-enum-api-path-params]]
  49. ==== {api-path-parms-title}
  50. `<target>`::
  51. (Required, string) Comma-separated list of data streams, indices, and aliases
  52. to search. Supports wildcards (`*`). To search all data streams or indices, omit
  53. this parameter or use `*` or `_all`.
  54. [[search-terms-enum-api-request-body]]
  55. ==== {api-request-body-title}
  56. [[terms-enum-field-param]]
  57. `field`::
  58. (Mandatory, string)
  59. Which field to match
  60. [[terms-enum-string-param]]
  61. `string`::
  62. (Optional, string)
  63. The string to match at the start of indexed terms. If not provided, all terms in the field
  64. are considered.
  65. [[terms-enum-size-param]]
  66. `size`::
  67. (Optional, integer)
  68. How many matching terms to return. Defaults to 10
  69. [[terms-enum-timeout-param]]
  70. `timeout`::
  71. (Optional, <<time-units,time value>>)
  72. The maximum length of time to spend collecting results. Defaults to "1s" (one second).
  73. If the timeout is exceeded the `complete` flag set to false in the response and the results may
  74. be partial or empty.
  75. [[terms-enum-case_insensitive-param]]
  76. `case_insensitive`::
  77. (Optional, boolean)
  78. When true the provided search string is matched against index terms without case sensitivity.
  79. Defaults to false.
  80. [[terms-enum-index_filter-param]]
  81. `index_filter`::
  82. (Optional, <<query-dsl,query object>> Allows to filter an index shard if the provided
  83. query rewrites to `match_none`.
  84. [[terms-enum-search_after-param]]
  85. `search_after`::
  86. (Optional, string)
  87. The string after which terms in the index should be returned. Allows for a form of
  88. pagination if the last result from one request is passed as the `search_after`
  89. parameter for a subsequent request.