Excluding inner_hits from top_hits aggregation

I have the following query into a product index, where the product has nested variants.

{
  "size": 10,
  "_source": {
    "excludes": "variants"
  },
  "query": {
    "bool": {
      "must": [
        {
          "nested": {
            "query": {
              "bool": {
                "filter": [
                  {
                    "term": {
                      "variants.assortmentIds": {
                        "value": "1"
                      }
                    }
                  }
                ]
              }
            },
            "path": "variants",
            "inner_hits": {
              "name": "variant_hits"
            }
          }
        }
      ]
    }
  },
  "aggs": {
    "designer": {
      "terms": {
        "field": "designerName",
        "size": 1000
      },
      "aggs": {
        "facet_value": {
          "top_hits": {
            "size": 1,
            "_source": {
              "includes": [
                "designerName"
              ]
            }
          }
        }
      }
    }
  }
}

In order to reduce the amount of data returned by the query, we exclude the "variants" field from the source, and get the matching variants with the "inner_hits".

The problem now is, that in my "top_hits" aggregation, I also get the entire "inner_hits" list. I really just want the "designerName" field from the top hit, and nothing else.

How can I exclude the "inner_hits" data in my "top_hits" aggregation?

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