Hello,
I have two similar documents in two different indices.
My score is correct in only one of them.
This is my document :
{
"id": 1,
"colors": {
"colorA": {
"hue": 50,
"population": 0.5
},
"colorB": {
"hue": 90,
"population": 0.00003
},
}
}
I want to use population
as the score when one color matches my query.
I'm using field_value_factor
in my query like this :
{
"query": {
"nested": {
"path": "colors",
"query": {
"function_score": {
"query": {
"match": {
"colors.colorA.hue": 50
}
},
"field_value_factor": {
"field": "colors.colorA.population"
},
"boost_mode": "replace"
}
}
}
}
}
If I use the explain API on a "new" index I get the correct score of 0.5 :
"value": 0.5,
"description": "min of:",
"details": [
{
"value": 0.5,
"description": "field value function: none(doc['colors.colorA.population'].value * factor=1.0)",
"details": [ ]
}, ...
]
...
But if I do the same on an index containing many other similar documents I get a wrong score of 0 :
"value": 0,
"description": "min of:",
"details": [
{
"value": 0,
"description": "field value function: none(doc['colors.colorA.population'].value * factor=1.0)",
"details": [ ]
}, ...
]
...
Strangely, if I change the field to colorB.population
"field_value_factor": {
"field": "colors.colorB.population"
},
I get the expected behaviour (score of 0.00003 ) :
"value": 0.00003,
"description": "min of:",
"details": [
{
"value": 0.00003,
"description": "field value function: none(doc['colors.colorA.population'].value * factor=1.0)",
"details": [ ]
}, ...
]
...
I've made a lot of tries but I can't quite understand why is my score wrong when I use colors.colorA.population
and not colors.colorB.population
, and why is it working on a "new" index but not on another one ?
This issue seems related to mine: Field value factor ignoring fields with a value less than one
But I create my index I use the type nested
for my colors array.
Thanks for your help