2015-08-06 11:24:29 -04:00
|
|
|
[[include-in-all]]
|
|
|
|
=== `include_in_all`
|
|
|
|
|
|
|
|
The `include_in_all` parameter provides per-field control over which fields
|
|
|
|
are included in the <<mapping-all-field,`_all`>> field. It defaults to `true`, unless <<mapping-index,`index`>> is set to `no`.
|
|
|
|
|
|
|
|
This example demonstrates how to exclude the `date` field from the `_all` field:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"mappings": {
|
|
|
|
"my_type": {
|
|
|
|
"properties": {
|
|
|
|
"title": { <1>
|
2016-03-18 12:01:27 -04:00
|
|
|
"type": "text"
|
2015-08-06 11:24:29 -04:00
|
|
|
}
|
|
|
|
"content": { <1>
|
2016-03-18 12:01:27 -04:00
|
|
|
"type": "text"
|
2015-08-06 11:24:29 -04:00
|
|
|
},
|
|
|
|
"date": { <2>
|
|
|
|
"type": "date",
|
|
|
|
"include_in_all": false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------
|
|
|
|
// AUTOSENSE
|
|
|
|
|
|
|
|
<1> The `title` and `content` fields with be included in the `_all` field.
|
|
|
|
<2> The `date` field will not be included in the `_all` field.
|
|
|
|
|
2015-08-12 15:21:37 -04:00
|
|
|
TIP: The `include_in_all` setting is allowed to have different settings for
|
|
|
|
fields of the same name in the same index. Its value can be updated on
|
|
|
|
existing fields using the <<indices-put-mapping,PUT mapping API>>.
|
|
|
|
|
|
|
|
|
2015-08-06 11:24:29 -04:00
|
|
|
The `include_in_all` parameter can also be set at the type level and on
|
|
|
|
<<object,`object`>> or <<nested,`nested`>> fields, in which case all sub-
|
|
|
|
fields inherit that setting. For instance:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------
|
|
|
|
PUT my_index
|
|
|
|
{
|
|
|
|
"mappings": {
|
|
|
|
"my_type": {
|
|
|
|
"include_in_all": false, <1>
|
|
|
|
"properties": {
|
2016-03-18 12:01:27 -04:00
|
|
|
"title": { "type": "text" },
|
2015-08-06 11:24:29 -04:00
|
|
|
"author": {
|
|
|
|
"include_in_all": true, <2>
|
|
|
|
"properties": {
|
2016-03-18 12:01:27 -04:00
|
|
|
"first_name": { "type": "text" },
|
|
|
|
"last_name": { "type": "text" }
|
2015-08-06 11:24:29 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"editor": {
|
|
|
|
"properties": {
|
2016-03-18 12:01:27 -04:00
|
|
|
"first_name": { "type": "text" }, <3>
|
|
|
|
"last_name": { "type": "text", "include_in_all": true } <3>
|
2015-08-06 11:24:29 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------
|
|
|
|
// AUTOSENSE
|
|
|
|
|
|
|
|
<1> All fields in `my_type` are excluded from `_all`.
|
|
|
|
<2> The `author.first_name` and `author.last_name` fields are included in `_all`.
|
|
|
|
<3> Only the `editor.last_name` field is included in `_all`.
|
|
|
|
The `editor.first_name` inherits the type-level setting and is excluded.
|
|
|
|
|
|
|
|
[NOTE]
|
|
|
|
.Multi-fields and `include_in_all`
|
|
|
|
=================================
|
|
|
|
|
|
|
|
The original field value is added to the `_all` field, not the terms produced
|
|
|
|
by a field's analyzer. For this reason, it makes no sense to set
|
|
|
|
`include_in_all` to `true` on <<multi-fields,multi-fields>>, as each
|
|
|
|
multi-field has exactly the same value as its parent.
|
|
|
|
|
|
|
|
=================================
|