Find Unique values of field while using match query on other field

Hello,

I would like find all unique set values of field3 that roll up under a specific value of field1 and a specific value of field2.

I've tried collapsing on field3 but it gives me the error that no mapping was found for that field in order to collapse on.

I need a query that works like this, however this query just gives documents for that filter and not the distinct values for field3:

GET my_index/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "match_phrase": {
            "field1": "value1"
          }
        },
        {
          "match_phrase": {
            "field2": "value2"
          }
        },
        {
          "range": {
            "timestamp": {
              "gte": "now-4d",
              "lte": "now"
            }
          }
        }
      ]
    }
  },
  "aggs" : {
    "langs" : {
        "terms" : { "field" : "field3",  "size" : 500 }
    }
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.