Hi @amyc,
You can add _score to your sort fields and track its value:
POST likes/doc/_bulk
{"index":{"_id": 1}}
{"likes": 10, "user": "john", "message": "elastic"}
{"index":{"_id": 2}}
{"likes": 20, "user": "john", "message": "elastic"}
{"index":{"_id": 3}}
{"likes": 5, "user": "ryan", "message": "elastic"}
{"index":{"_id": 4}}
{"likes": 10, "user": "ryan", "message": "elastic"}
GET likes/_search
{
"track_scores": "true",
"query": {
"match": {
"message": "elastic"
}
},
"collapse": {
"field": "user.keyword"
},
"sort": [
"likes",
"_score"
]
}
Response:
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 4,
"max_score": 0.2876821,
"hits": [
{
"_index": "likes",
"_type": "doc",
"_id": "3",
"_score": 0.2876821,
"_source": {
"likes": 5,
"user": "ryan",
"message": "elastic"
},
"fields": {
"user.keyword": [
"ryan"
]
},
"sort": [
5,
0.2876821
]
},
{
"_index": "likes",
"_type": "doc",
"_id": "1",
"_score": 0.2876821,
"_source": {
"likes": 10,
"user": "john",
"message": "elastic"
},
"fields": {
"user.keyword": [
"john"
]
},
"sort": [
10,
0.2876821
]
}
]
}
}
Hope it helps.
Cheers,
LG