4

使用elasticsearch 0.19.4(我知道这是旧的,但它是依赖项所需要的)

我在弹性搜索索引中有一个“摘要”字段 - 我想执行一个查询,该查询将返回所有摘要值重复的情况。这可以做到吗?

对于具有重复值的记录,我想返回其他值 - 例如可能不重复的“url”。

4

1 回答 1

3

You can use Terms Aggregation for this.

POST <index>/<type>/_search?search_type=count
{
    "aggs": {
       "duplicateNames": {
           "terms": {
               "field": "digest",
               "size": 0,
               "min_doc_count": 2
            }
        }
    }
}

This will return all values of the field digest which occur in at least 2 documents. I agree this does not exactly match to your use case but it might help.

于 2015-10-01T06:13:55.560 回答