Hello, I have a related question that I couldn't get from the previous discussion.
I want to boost by a nested object field but a filtered one. Let's say I have this documents:
POST /test/doc/1
{
"title": "doc 1",
"queries":
[
{
"hash": "102a",
"value": 0.9
},
{
"hash": "101a",
"value": 0.9
}
]
}
POST /test/doc/2
{
"title": "doc 2",
"queries":
[
{
"hash": "102a",
"value": 1.0
},
{
"hash": "101a",
"value": 0.8
}
]
}
POST /test/doc/3
{
"title": "doc 3",
"queries":
[
{
"hash": "103a",
"value": 0.9
},
{
"hash": "101a",
"value": 0.3
}
]
}
I want to match all documents but boost those ones that have a specific hash value:
GET /test/doc/_search
{
"query": {
"nested": {
"path": "queries",
"query": {
"function_score": {
"query": { "match_all": {} },
"functions": [
{
"field_value_factor": {
"field": "queries.value",
"missing": 0
},
"filter": {
"match": {"queries.hash": "102a"}
}
}
]
}
}
}
}
}
With this query I expected doc 2, doc1 and doc 3 were returned in this order, given I am using the queries.value for the hash value 102a. However, the result is not that. I have a different order and a constant score of 1 for each document.
Could you please point any mistakes in my query or tell me if is not possible to have this with nested documents in function scores.
thank you!