- Using Elasticsearch v6.5
Hi, I am using function_score query with field_value_factor on a date field. My query is following:
POST /users/_search
{
"query": {
"function_score": {
"query": {
"match_all": {}
},
"functions": [
{
"field_value_factor": {
"field": "createdAt"
}
}
]
}
}
}
Response
200 OK
{
"hits": {
"hits": [
{
"_score": 1545536870000000,
"_type": "_doc",
"_id": "user1",
"_source": {
"createdAt": 1545536877421,
"firstName": "foo1"
},
"_index": "users"
},
{
"_score": 1545536870000000,
"_type": "_doc",
"_id": "user2",
"_source": {
"createdAt": 1545536877422,
"firstName": "foo2"
},
"_index": "users"
}
],
"max_score": 1545536870000000
},
"took": 17
}
My Question are: 1. why it returned same score for both the documents even when the field's values are different? 2. why the score trimmed the actual field value into a smaller value and then multiple by 10000000. Isn't the whole point of using field value factor is to score those documents higher which has higher field value.