include-in-all.asciidoc 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. The `include_in_all` parameter can also be set at the type level and on
  32. <<object,`object`>> or <<nested,`nested`>> fields, in which case all sub-
  33. fields inherit that setting. For instance:
  34. [source,js]
  35. --------------------------------
  36. PUT my_index
  37. {
  38. "mappings": {
  39. "my_type": {
  40. "include_in_all": false, <1>
  41. "properties": {
  42. "title": { "type": "string" },
  43. "author": {
  44. "include_in_all": true, <2>
  45. "properties": {
  46. "first_name": { "type": "string" },
  47. "last_name": { "type": "string" }
  48. }
  49. },
  50. "editor": {
  51. "properties": {
  52. "first_name": { "type": "string" }, <3>
  53. "last_name": { "type": "string", "include_in_all": true } <3>
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. --------------------------------
  61. // AUTOSENSE
  62. <1> All fields in `my_type` are excluded from `_all`.
  63. <2> The `author.first_name` and `author.last_name` fields are included in `_all`.
  64. <3> Only the `editor.last_name` field is included in `_all`.
  65. The `editor.first_name` inherits the type-level setting and is excluded.
  66. [NOTE]
  67. .Multi-fields and `include_in_all`
  68. =================================
  69. The original field value is added to the `_all` field, not the terms produced
  70. by a field's analyzer. For this reason, it makes no sense to set
  71. `include_in_all` to `true` on <<multi-fields,multi-fields>>, as each
  72. multi-field has exactly the same value as its parent.
  73. =================================