We have defined ProjectContract and RepositoryContract with parent child relationships.
Running rescore query updates the scores of parent document. And returns the list of the parent documents arranged in descending order based on the new score. But child documents are still ordered based upon their old score.
Let's say search returns following results:-
P1 -> C1, C2
Query score of C1 = 1, C2 = 0.8
Rescore score of C1 = 0.5, C2 = 0.8
Now ES will return results as P1 { C1, C2} instead of P1 { C2, C1}.
Since C2 = 0.8 +0.8 = 1.6. And C1 = 1.5.
Is there a way to order child documents with Rescore qurey?
Query:-
{
"explain": true,
"rescore": {
"query": {
"rescore_query": {
"bool": {
"should": [
{
"multi_match": {
"type": "phrase",
"query": "mount everest",
"slop": 25,
"tie_breaker": 0.0,
"fields": [
"description^5"
]
}
},
{
"has_child": {
"type": "RepositoryContract",
"score_mode": "sum",
"query": {
"multi_match": {
"type": "phrase",
"query": "mount everest",
"slop": 25,
"tie_breaker": 0.0,
"fields": [
"readme^1"
]
}
}
}
}
]
}
},
"query_weight": 1.0,
"rescore_query_weight": 1.0
}
},
"_source": {
"include": [
"name",
"description"
]
},
"query": {
"bool": {
"must": {
"bool": {
"should": [
{
"bool": {
"must": [
{
"multi_match": {
"query": "mount",
"type": "phrase",
"fields": [
"description^5"
],
"tie_breaker": 0
}
},
{
"multi_match": {
"query": "everest",
"type": "phrase",
"fields": [
"description^5"
],
"tie_breaker": 0
}
}
]
}
},
{
"has_child": {
"type": "RepositoryContract",
"score_mode": "sum",
"query": {
"bool": {
"must": [
{
"multi_match": {
"query": "mount",
"type": "phrase",
"fields": [
"readme^1"
],
"tie_breaker": 0
}
},
{
"multi_match": {
"query": "everest",
"type": "phrase",
"fields": [
"readme^1"
],
"tie_breaker": 0
}
}
]
}
},
"inner_hits": {
"size": 3
}
}
}
],
"minimum_should_match": 1
}
}
}
}
}