include-in-all.asciidoc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. [[include-in-all]]
  2. === `include_in_all`
  3. The `include_in_all` parameter provides per-field control over which fields
  4. are included in the <<mapping-all-field,`_all`>> field. It defaults to `true`, unless <<mapping-index,`index`>> is set to `no`.
  5. This example demonstrates how to exclude the `date` field from the `_all` field:
  6. [source,js]
  7. --------------------------------
  8. PUT my_index
  9. {
  10. "mappings": {
  11. "my_type": {
  12. "properties": {
  13. "title": { <1>
  14. "type": "string"
  15. }
  16. "content": { <1>
  17. "type": "string"
  18. },
  19. "date": { <2>
  20. "type": "date",
  21. "include_in_all": false
  22. }
  23. }
  24. }
  25. }
  26. }
  27. --------------------------------
  28. // AUTOSENSE
  29. <1> The `title` and `content` fields with be included in the `_all` field.
  30. <2> The `date` field will not be included in the `_all` field.
  31. TIP: The `include_in_all` setting is allowed to have different settings for
  32. fields of the same name in the same index. Its value can be updated on
  33. existing fields using the <<indices-put-mapping,PUT mapping API>>.
  34. The `include_in_all` parameter can also be set at the type level and on
  35. <<object,`object`>> or <<nested,`nested`>> fields, in which case all sub-
  36. fields inherit that setting. For instance:
  37. [source,js]
  38. --------------------------------
  39. PUT my_index
  40. {
  41. "mappings": {
  42. "my_type": {
  43. "include_in_all": false, <1>
  44. "properties": {
  45. "title": { "type": "string" },
  46. "author": {
  47. "include_in_all": true, <2>
  48. "properties": {
  49. "first_name": { "type": "string" },
  50. "last_name": { "type": "string" }
  51. }
  52. },
  53. "editor": {
  54. "properties": {
  55. "first_name": { "type": "string" }, <3>
  56. "last_name": { "type": "string", "include_in_all": true } <3>
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. --------------------------------
  64. // AUTOSENSE
  65. <1> All fields in `my_type` are excluded from `_all`.
  66. <2> The `author.first_name` and `author.last_name` fields are included in `_all`.
  67. <3> Only the `editor.last_name` field is included in `_all`.
  68. The `editor.first_name` inherits the type-level setting and is excluded.
  69. [NOTE]
  70. .Multi-fields and `include_in_all`
  71. =================================
  72. The original field value is added to the `_all` field, not the terms produced
  73. by a field's analyzer. For this reason, it makes no sense to set
  74. `include_in_all` to `true` on <<multi-fields,multi-fields>>, as each
  75. multi-field has exactly the same value as its parent.
  76. =================================