field-caps.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. [[search-field-caps]]
  2. === Field Capabilities API
  3. Allows you to retrieve the capabilities of fields among multiple indices.
  4. [source,console]
  5. --------------------------------------------------
  6. GET /_field_caps?fields=rating
  7. --------------------------------------------------
  8. [[search-field-caps-api-request]]
  9. ==== {api-request-title}
  10. `GET /_field_caps`
  11. `POST /_field_caps`
  12. `GET /<index>/_field_caps`
  13. `POST /<index>/_field_caps`
  14. [[search-field-caps-api-desc]]
  15. ==== {api-description-title}
  16. The field capabilities API returns the information about the capabilities of
  17. fields among multiple indices.
  18. [[search-field-caps-api-path-params]]
  19. ==== {api-path-parms-title}
  20. include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
  21. [[search-field-caps-api-query-params]]
  22. ==== {api-query-parms-title}
  23. include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
  24. include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
  25. +
  26. --
  27. Defaults to `open`.
  28. --
  29. include::{docdir}/rest-api/common-parms.asciidoc[tag=fields]
  30. include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
  31. `include_unmapped`::
  32. (Optional, boolean) If `true`, unmapped fields are included in the response.
  33. Defaults to `false`.
  34. [[search-field-caps-api-response-body]]
  35. ==== {api-response-body-title}
  36. `searchable`::
  37. Whether this field is indexed for search on all indices.
  38. `aggregatable`::
  39. Whether this field can be aggregated on all indices.
  40. `indices`::
  41. The list of indices where this field has the same type, or null if all indices
  42. have the same type for the field.
  43. `non_searchable_indices`::
  44. The list of indices where this field is not searchable, or null if all indices
  45. have the same definition for the field.
  46. `non_aggregatable_indices`::
  47. The list of indices where this field is not aggregatable, or null if all
  48. indices have the same definition for the field.
  49. [[search-field-caps-api-example]]
  50. ==== {api-examples-title}
  51. The request can be restricted to specific indices:
  52. [source,console]
  53. --------------------------------------------------
  54. GET twitter/_field_caps?fields=rating
  55. --------------------------------------------------
  56. // TEST[setup:twitter]
  57. The next example API call requests information about the `rating` and the
  58. `title` fields:
  59. [source,console]
  60. --------------------------------------------------
  61. GET _field_caps?fields=rating,title
  62. --------------------------------------------------
  63. The API returns the following response:
  64. [source,console-result]
  65. --------------------------------------------------
  66. {
  67. "indices": ["index1", "index2", "index3", "index4", "index5"],
  68. "fields": {
  69. "rating": { <1>
  70. "long": {
  71. "searchable": true,
  72. "aggregatable": false,
  73. "indices": ["index1", "index2"],
  74. "non_aggregatable_indices": ["index1"] <2>
  75. },
  76. "keyword": {
  77. "searchable": false,
  78. "aggregatable": true,
  79. "indices": ["index3", "index4"],
  80. "non_searchable_indices": ["index4"] <3>
  81. }
  82. },
  83. "title": { <4>
  84. "text": {
  85. "searchable": true,
  86. "aggregatable": false
  87. }
  88. }
  89. }
  90. }
  91. --------------------------------------------------
  92. // TESTRESPONSE[skip:historically skipped]
  93. <1> The field `rating` is defined as a long in `index1` and `index2`
  94. and as a `keyword` in `index3` and `index4`.
  95. <2> The field `rating` is not aggregatable in `index1`.
  96. <3> The field `rating` is not searchable in `index4`.
  97. <4> The field `title` is defined as `text` in all indices.
  98. By default unmapped fields are ignored. You can include them in the response by
  99. adding a parameter called `include_unmapped` in the request:
  100. [source,console]
  101. --------------------------------------------------
  102. GET _field_caps?fields=rating,title&include_unmapped
  103. --------------------------------------------------
  104. In which case the response will contain an entry for each field that is present
  105. in some indices but not all:
  106. [source,console-result]
  107. --------------------------------------------------
  108. {
  109. "indices": ["index1", "index2", "index3"],
  110. "fields": {
  111. "rating": {
  112. "long": {
  113. "searchable": true,
  114. "aggregatable": false,
  115. "indices": ["index1", "index2"],
  116. "non_aggregatable_indices": ["index1"]
  117. },
  118. "keyword": {
  119. "searchable": false,
  120. "aggregatable": true,
  121. "indices": ["index3", "index4"],
  122. "non_searchable_indices": ["index4"]
  123. },
  124. "unmapped": { <1>
  125. "indices": ["index5"],
  126. "searchable": false,
  127. "aggregatable": false
  128. }
  129. },
  130. "title": {
  131. "text": {
  132. "indices": ["index1", "index2", "index3", "index4"],
  133. "searchable": true,
  134. "aggregatable": false
  135. },
  136. "unmapped": { <2>
  137. "indices": ["index5"]
  138. "searchable": false,
  139. "aggregatable": false
  140. }
  141. }
  142. }
  143. }
  144. --------------------------------------------------
  145. // TESTRESPONSE[skip:historically skipped]
  146. <1> The `rating` field is unmapped` in `index5`.
  147. <2> The `title` field is unmapped` in `index5`.