field-caps.asciidoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. "fields": {
  50. "rating": { <1>
  51. "long": {
  52. "searchable": true,
  53. "aggregatable": false,
  54. "indices": ["index1", "index2"],
  55. "non_aggregatable_indices": ["index1"] <2>
  56. },
  57. "keyword": {
  58. "searchable": false,
  59. "aggregatable": true,
  60. "indices": ["index3", "index4"],
  61. "non_searchable_indices": ["index4"] <3>
  62. }
  63. },
  64. "title": { <4>
  65. "text": {
  66. "searchable": true,
  67. "aggregatable": false
  68. }
  69. }
  70. }
  71. }
  72. --------------------------------------------------
  73. // NOTCONSOLE
  74. <1> The field `rating` is defined as a long in `index1` and `index2`
  75. and as a `keyword` in `index3` and `index4`.
  76. <2> The field `rating` is not aggregatable in `index1`.
  77. <3> The field `rating` is not searchable in `index4`.
  78. <4> The field `title` is defined as `text` in all indices.