-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Fix nested aggregation top_hits with query inner_hits #137351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Top_hits aggregations inside nested aggregations were inheriting the parent query's inner_hits context, causing conflicting fetch scopes and nested source extraction to fail with "Error retrieving path". When top_hits is a child of NestedAggregator, now creates an empty InnerHitsContext to prevent InnerHitsPhase from running. Closes elastic#136893
|
Hi @mayya-sharipova, I've created a changelog YAML for you. |
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
@mayya-sharipova maybe I misunderstand how this will look for users. But as a user, I would still expect to get inner hits for both whenever I request them. One that is present within |
|
@benwtrent Thanks for your comment. This fix applies only when top_hits agg is a part of nested. When we do
|
|
@benwtrent I've checked an it looks like inner_hits for double nested fields in top_hits doesn't work (for most docs doesn't return anything). PUT comments
{
"mappings": {
"properties": {
"product": {
"type": "keyword"
},
"comments": {
"type": "nested",
"properties": {
"comment": {
"type": "text"
},
"user": {
"type" : "keyword"
},
"ratings": {
"type": "nested",
"properties": {
"rating": {
"type": "integer"
},
"user": {
"type": "keyword"
}
}
}
}
}
}
}
}
POST /comments/_search?_source=false
{
"aggs": {
"nested_ratings": {
"nested": {
"path": "comments"
},
"aggs": {
"ratings_top_hits": {
"top_hits": {
"size": 10
}
}
}
}
},
"query": {
"nested": {
"inner_hits": {},
"path": "comments",
"query": {
"match_all": {}
}
}
}
} |
Currently
top_hitsaggs inside nested aggs inherit the parentquery's inner_hits context, causing an error "Error retrieving path".
This happenes because nested top_hits is already operating on nested child docs,
and asking it to retrieve inner_hits adds an extra incorrect level of nestedness.
This fix proposes to create an empty InnerHitsContext for this case.
Closes #136893