弹性搜索 5.0 重复 removal/optimisation

Elastic search 5.0 duplicate removal/optimisation

从 ES 5.0 开始,默认情况下在文本字段上禁用 Fielddata。我如何删除重复项/使用现有设置获得相同的结果,即当在下面的查询中禁用字段数据时?

{
  "aggs": {
    "query": {
      "terms": {
        "field": "name"
      }
     ,
      "aggs": {
        "top": {
          "top_hits": {
            "size": 1
          }
        }


      }
    }
  },
  "size": 0,
  "query": {

          "multi_match": {
            "query": "laura",
            "operator": "OR",
            "fields": [

              "name"

            ]
          }
  }
}

你必须 enable fielddata on text fields for ES 5.x. Use it with caution 因为它消耗大量堆 space。

更新您的映射
PUT your_index/_mapping/your_type
{
  "properties": {
    "name": { 
      "type":     "text",
      "fielddata": true
    }
  }
}

然后 运行 查询。