# Collapse on nested inner hits

**URL:** <https://discuss.elastic.co/t/collapse-on-nested-inner-hits/232553>\
**Category:** Elasticsearch\
**Created:** [May 14, 2020, 6:02am UTC](https://discuss.elastic.co/t/collapse-on-nested-inner-hits/232553 "2020-05-14T06:02:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mekanix](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@mekanix](https://discuss.elastic.co/u/mekanix)\
**Post date:** [May 14, 2020, 6:02am UTC](https://discuss.elastic.co/t/collapse-on-nested-inner-hits/232553/1 "2020-05-14T06:02:33Z")

</div>

Can you do collapse on inner\_hits like this:

```
{
  "query": {
    "bool": {
      "filter": [
        {
          "nested": {
            "path": "foo",
            "query": {
              "match_all": {}
            },
            "inner_hits": {
              "collapse": {
                "field": "foo.id"
              }
            }
          }
        }
      ]
    }
  }
}

```

I can't find anything in the docs that says you can do this, but after reading this: [https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#\_second\_level\_of\_collapsing](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-request-body.html#_second_level_of_collapsing) I got curious. I can insert the collapse object into inner\_hits without getting any errors. Same goes for any values I insert into field. I would expect an error if it wasn't supported, but AFAICT it have no impact.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 11, 2020, 6:02am UTC](https://discuss.elastic.co/t/collapse-on-nested-inner-hits/232553/2 "2020-06-11T06:02:38Z")

</div>

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