I am using functions score with sampler aggregation to match last visited documents.
ES Query
{
"query": {
"function_score": {
"boost_mode": "replace", // we need to replace document score with the result of the functions,
"query": {
},
"functions": [
{
"field_value_factor": { // return `lastvisited` value as score
"field": "visited_time"
}
,"weight":1
}
]
}
},
"size": 10000
}
Response
{
"took" : 5,
"timed_out" : false,
"_shards" : {
"total" : 2,
"successful" : 2,
"failed" : 0
},
"hits" : {
"total" : 5,
"max_score" : 1.45973969E12,
"hits" : [ {
"_index" : "idx0",
"_type" : "8001",
"_id" : "null-100-1459739724631",
"_score" : 1.45973969E12,
"_routing" : "100",
"_source" : {
"visited_time" : 1459739724636
}
}, {
"_index" : "idx0",
"_type" : "8001",
"_id" : "null-101-1459708570522",
"_score" : 1.45970862E12,
"_routing" : "101",
"_source" : {
"visited_time" : 1459708570525
}
}, {
"_index" : "idx0",
"_type" : "8001",
"_id" : "null-101-1459708599619",
"_score" : 1.45970862E12,
"_routing" : "101",
"_source" : {
"visited_time" : 1459708599620
}
}, {
"_index" : "idx0",
"_type" : "8001",
"_id" : "null-100-1459708476386",
"_score" : 1.45970849E12,
"_routing" : "100",
"_source" : {
"visited_time" : 1459708476387
}
}, {
"_index" : "idx0",
"_type" : "8001",
"_id" : "null-100-1459708421417",
"_score" : 1.45970836E12,
"_routing" : "100",
"_source" : {
"visited_time" : 1459708421492
}
} ]
}
}
I don't know why it returns same document score?