是的,您可以通过在最大文档分数上添加另一个子聚合并按
unique
terms该分数对聚合进行排序来实现。
curl -XGET "http://localhost:9200/myidx/product/_search?search_type=count" -d '{ "size": 2, "query": { "function_score": { "field_value_factor": {"field": "relevance","factor": 2.0 }, "query": { "term": { "title": "abcd" } }, "score_mode": "multiply", "boost_mode": "multiply" } }, "aggs": { "unique": { "terms": {"field": "groupid","size": 2,"order": { "max_score": "desc"} }, "aggs": {"max_score": { "max": { "script": "doc.score" }},"sample": { "top_hits": { "size": 1 }} } } }}'


