Find distinct values, not distinct counts in elasticsearch

前端 未结 4 1091
陌清茗
陌清茗 2020-11-30 06:38

Elasticsearch documentation suggests* that their piece of code

*documentation fixed

GET /cars/transactions/_search?search_type=         


        
4条回答
  •  孤城傲影
    2020-11-30 07:09

    To update the excellent answer from Andrei Stefan, we need to say that the query parameter search_type=count is no more supported in Elasticsearch 5. The new way of doing this is to add "size" : 0 in the body such as :

    GET /cars/transactions/_search
    {
      "size": 0,
      "aggs": {
        "distinct_colors": {
          "terms": {
            "field": "color",
            "size": 1000
          }
        }
      }
    }
    

提交回复
热议问题