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
Nested documents _score is overwritten by the root document _score #23329
Comments
Pinging @elastic/es-search-aggs |
We discussed it, and decided to add another optional parameter to the |
Sounds really great! Could you give a guess how this will affect performance? Will the same query run multiple times, once during the query phase and once during the aggregation phase? |
@volodymyrpavlenko I think your problem could be solved without even introducing any modifications to the code, but just using "query": {
"query": {
"nested": {
"query": {
"match": {
"children.name": {
"query": "<free-text-search>",
"type": "boolean",
"operator": "AND",
"analyzer": "standard",
"boost": 1.0
}
}
},
"path": "children"
}
}
},
"rescore" : {
"query" : {
"rescore_query" : {
"match": {
"children.name": {
"query": "<free-text-search>",
"type": "boolean",
"operator": "AND",
"analyzer": "standard",
"boost": 1.0
}
}
},
"query_weight" : 0,
"rescore_query_weight" : 1
}
} Then the nested docs in the |
Hi @volodymyrpavlenko did you have the chance to check this out? We would like to know whether the proposed solution works for you. |
No further feedback received. @volodymyrpavlenko let us know if you get to check this out and we can look at re-opening this issue. |
I'm currently trying to implement a query to make a scored search on a nested document and then perform an aggregation on the hits. I also need to sort the aggregations according to the score of the nested document.
A very simplified mapping can be described:
To achieve the initial requirement, I used technique that is called "field collapse". The query looks like this:
It works fine as long as we have one child per parent. But this stops working when we get multiple children per parent.
Investigating the reasons, I found that the problem is that nested document _score is actually taken from the root document, even though it is displayed correctly in inner_docs if I output them.
I tested this in 1.7.1 and 2.4.3 and the problem persists.
The text was updated successfully, but these errors were encountered: