Query regarding aggregations in elastic search for nested objects?


(Kartheek Gummaluri) #1

I need to query the data using aggregation.My questions I have nested object and I try the query but my question how to do multiple aggregation based on the field which is not in nested object.

Please find the query you may get the idea

GET dealytics2/deal/_search
{
  "size": 0, 
  "_source": {
    "includes": [
      "master_deal_no",
      "advisors.advisor_type"
    ]
  },
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "path": "advisors",
            "query": {
              "bool": {
                "should": [
                  {
                    "match_phrase": {
                      "advisors.advisor_type": "Buyer advisors, non-lawyers"
                    }
                  },
                  {
                    "match_phrase": {
                      "advisors.advisor_type": "Target_advisors, non-lawyers"
                    }
                  }
                ]
              }
            }
          }
        },
        {
          "range": {
            "rank_date": {
              "gte": "01/01/2012",
              "lte": "31/12/2013",
              "format": "dd/MM/yyyy||yyyy"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "bankers": {
      "nested": {
        "path": "advisors"
      },
      "aggs": {
        "bankers1": {
          "terms": {
            "field": "advisors.advisor"
          }
        }
      }
    }
  }
}

(Colin Goodheart-Smithe) #2

Could you explain a bit more about the problem you are trying to solve:

  • What doesn't work with the request you have provided?
  • What do you documents look like?
  • What do you mappings look like?
  • What are you looking for as the expected result?

(system) #3

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