HI,
I have a nested object on my mappings with multiple values. Every user has a set of capacities each capacity has a number of points that describes the level of the user in that capacity.
{
"userId": "1",
"usertype": 2,
"capacities": [{
"id": "capacity1",
"score": 20
}, {
"id": "capacity3",
"score": 0
}, {
"id": "capacity2",
"score": 40
}]
},
{
"userId": "2",
"usertype": 2,
"capacities": [{
"id": "capacity1",
"score": 20
}, {
"id": "capacity4",
"score": 40
}, {
"id": "capacity2",
"score": 10
}]
}
I want to create a query that rank the result using a set of capacities, I'm trying to use function score with field value factor.
{
"query": {
"function_score": {
"query": {
"bool": {
"should": [
{
"nested": {
"path": "capacities",
"query": {
"function_score": {
"query": {
"term": {
"capacities.id": {
"value": "capacity1"
},
"boost": 1
}
},
"functions": [
{
"field_value_factor": {
"field": "capacities.score",
"modifier": "log1p",
"factor": 1
}
}
]
}
}
}
}
]
}
}
}
}
}
The matched nested document for capacity1 has a score of 20, I expect to get is a ES score which is log(21), but I'm not getting such value. here is my explain
"_explanation": {
"value": 6.8698506,
"description": "sum of:",
"details": [{
"value": 6.8698506,
"description": "sum of:",
"details": [{
"value": 6.8698506,
"description": "Score based on child doc range from 193 to 221",
"details": []
}]
}]
}