docs: document alternative for nested inner hits source

Closes #24110
This commit is contained in:
Martijn van Groningen 2017-04-28 11:09:24 +02:00
parent 35f78d098a
commit b77254871b
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
1 changed files with 49 additions and 0 deletions

View File

@ -148,6 +148,55 @@ An important default is that the `_source` returned in hits inside `inner_hits`
So in the above example only the comment part is returned per nested hit and not the entire source of the top level So in the above example only the comment part is returned per nested hit and not the entire source of the top level
document that contained the comment. document that contained the comment.
[[nested-inner-hits-source]]
==== Nested inner hits and _source
Nested document don't have a `_source` field, because the entire source of document is stored with the root document under
its `_source` field. To include the source of just the nested document, the source of the root document is parsed and just
the relevant bit for the nested document is included as source in the inner hit. Doing this for each matching nested document
has an impact on the time it takes to execute the entire search request, especially when `size` and the inner hits' `size`
are set higher than the default. To avoid the relative expensive source extraction for nested inner hits, one can disable
including the source and solely rely on stored fields.
Enabled stored field for fields under the nested object field in your mapping:
[source,js]
--------------------------------------------------
{
"properties": {
"comment": {
"type": "comments",
"properties" : {
"message" : {
"type" : "text",
"store" : true
}
}
}
}
}
--------------------------------------------------
Disable including source and include specific stored fields in the inner hits definition:
[source,js]
--------------------------------------------------
{
"query" : {
"nested" : {
"path" : "comments",
"query" : {
"match" : {"comments.message" : "[actual query]"}
},
"inner_hits" : {
"_source" : false,
"stored_fields" : ["comments.text"]
}
}
}
}
--------------------------------------------------
[[hierarchical-nested-inner-hits]] [[hierarchical-nested-inner-hits]]
==== Hierarchical levels of nested object fields and inner hits. ==== Hierarchical levels of nested object fields and inner hits.