Skip to content Skip to sidebar Skip to footer

Elasticsearch Get Unique Values, And The Values Count On Multiple Fields

I want to get the list of unique values from a field, and at the same time, count how many times each of those unique values have appeared in two different fields. Let's say I have

Solution 1:

Try:

  body = {
  "size": 0,
  "aggs": {
    "sold": {
      "terms": {
        "field": "product.sold.keyword",
        "size": 40000
      },
      "aggs": {
        "bought": {
          "terms": {
            "field": "product.bought.keyword",
            "size": 40000
          }
        }
      }
    }
  }
}

Post a Comment for "Elasticsearch Get Unique Values, And The Values Count On Multiple Fields"