由于您正在使用排序,因此您需要为要计算的分数显式设置“
track_scores ”。
例:
{ "size": 1, "query": { "bool": { "must": [ { "match": {"_all": {"query": "test","operator": "and","fuzziness": "2"}}} ], "should": [ { "multi_match" : { "query": "test" ,"type": "best_fields" ,"fields": ["ObjectData.PRTNAME","ObjectData.EXTERNALID","ObjectData.contactList.VALUE","*SERIES","*NUMBER","ObjectData.INN"] ,"operator": "or" ,"boost": 3 }} ] } }, "aggs": { "byObjectID": { "terms": {"field": "ObjectID"}, "aggs": { "latestVer": { "top_hits": { "sort": [{"creationDate": { "order": "desc" }}] ,"_source": { "include": ["ObjectData.BRIEFNAME", "creationDate", "ObjectID" ]} ,"size": 1, 'track_scores" : 1 } } } } }}


