Collapse on nested inner hits

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 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.

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