field-caps.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. [[search-field-caps]]
  2. === Field Capabilities API
  3. The field capabilities API allows to retrieve the capabilities of fields among multiple indices.
  4. The field capabilities API by default executes on all indices:
  5. [source,js]
  6. --------------------------------------------------
  7. GET _field_caps?fields=rating
  8. --------------------------------------------------
  9. // CONSOLE
  10. The request can also be restricted to specific indices:
  11. [source,js]
  12. --------------------------------------------------
  13. GET twitter/_field_caps?fields=rating
  14. --------------------------------------------------
  15. // CONSOLE
  16. // TEST[setup:twitter]
  17. Supported request options:
  18. [horizontal]
  19. `fields`:: A list of fields to compute stats for. The field name supports wildcard notation. For example, using `text_*`
  20. will cause all fields that match the expression to be returned.
  21. [float]
  22. ==== Field Capabilities
  23. The field capabilities API returns the following information per field:
  24. [horizontal]
  25. `searchable`::
  26. Whether this field is indexed for search on all indices.
  27. `aggregatable`::
  28. Whether this field can be aggregated on all indices.
  29. `indices`::
  30. The list of indices where this field has the same type,
  31. or null if all indices have the same type for the field.
  32. `non_searchable_indices`::
  33. The list of indices where this field is not searchable,
  34. or null if all indices have the same definition for the field.
  35. `non_aggregatable_indices`::
  36. The list of indices where this field is not aggregatable,
  37. or null if all indices have the same definition for the field.
  38. [float]
  39. ==== Response format
  40. Request:
  41. [source,js]
  42. --------------------------------------------------
  43. GET _field_caps?fields=rating,title
  44. --------------------------------------------------
  45. // CONSOLE
  46. [source,js]
  47. --------------------------------------------------
  48. {
  49. "indices": ["index1", "index2", "index3", "index4", "index5"],
  50. "fields": {
  51. "rating": { <1>
  52. "long": {
  53. "searchable": true,
  54. "aggregatable": false,
  55. "indices": ["index1", "index2"],
  56. "non_aggregatable_indices": ["index1"] <2>
  57. },
  58. "keyword": {
  59. "searchable": false,
  60. "aggregatable": true,
  61. "indices": ["index3", "index4"],
  62. "non_searchable_indices": ["index4"] <3>
  63. }
  64. },
  65. "title": { <4>
  66. "text": {
  67. "searchable": true,
  68. "aggregatable": false
  69. }
  70. }
  71. }
  72. }
  73. --------------------------------------------------
  74. // NOTCONSOLE
  75. <1> The field `rating` is defined as a long in `index1` and `index2`
  76. and as a `keyword` in `index3` and `index4`.
  77. <2> The field `rating` is not aggregatable in `index1`.
  78. <3> The field `rating` is not searchable in `index4`.
  79. <4> The field `title` is defined as `text` in all indices.
  80. [float]
  81. ==== Unmapped fields
  82. By default unmapped fields are ignored. You can include them in the response by
  83. adding a parameter called `include_unmapped` in the request:
  84. [source,js]
  85. --------------------------------------------------
  86. GET _field_caps?fields=rating,title&include_unmapped
  87. --------------------------------------------------
  88. // CONSOLE
  89. In which case the response will contain an entry for each field that is present in
  90. some indices but not all:
  91. [source,js]
  92. --------------------------------------------------
  93. {
  94. "indices": ["index1", "index2", "index3"],
  95. "fields": {
  96. "rating": {
  97. "long": {
  98. "searchable": true,
  99. "aggregatable": false,
  100. "indices": ["index1", "index2"],
  101. "non_aggregatable_indices": ["index1"]
  102. },
  103. "keyword": {
  104. "searchable": false,
  105. "aggregatable": true,
  106. "indices": ["index3", "index4"],
  107. "non_searchable_indices": ["index4"]
  108. },
  109. "unmapped": { <1>
  110. "indices": ["index5"],
  111. "searchable": false,
  112. "aggregatable": false
  113. }
  114. },
  115. "title": {
  116. "text": {
  117. "indices": ["index1", "index2", "index3", "index4"],
  118. "searchable": true,
  119. "aggregatable": false
  120. },
  121. "unmapped": { <2>
  122. "indices": ["index5"]
  123. "searchable": false,
  124. "aggregatable": false
  125. }
  126. }
  127. }
  128. }
  129. --------------------------------------------------
  130. // NOTCONSOLE
  131. <1> The `rating` field is unmapped` in `index5`.
  132. <2> The `title` field is unmapped` in `index5`.