Skip to content

post filter not applied to field collapsing inner hits? #26649

@qwerty4030

Description

@qwerty4030

Elasticsearch version: 5.3.3

Plugins installed: [discovery-ec2, repository-s3, x-pack]

JVM version : 1.8.0_131 Java HotSpot(TM) 64-Bit Server VM

OS version : 3.13.0-121-generic AWS Ubuntu 14.04 LTS

Description of the problem including expected versus actual behavior: I recently started using the new field collapsing functionality and I noticed that the search post_filter is not applied to the inner_hits. This was surprising behavior to me because the post_filter applies to the collapsed search hits just fine and I did not see anything that said it wouldn't work. However I'm not 100% sure if this would be a bug or enhancement.

We use the post_filter for the typical faceted navigation use case and we wanted to leverage the new field collapse with inner_hits to add more variety to our search results. I guess a workaround would be to use a top_hits + filter aggregation to do the field collapse? Are there any significant performance differences between using the top_hits aggregation vs the new collapse functionality?

Steps to reproduce:

POST test-index/test-type/1
{
  "value":1,
  "common":1
}

POST test-index/test-type/2
{
  "value":2,
  "common":1
}

POST test-index/test-type/_search
{
  "collapse": {
    "field": "common",
    "inner_hits": {
      "name": "common"
    }
  },
  "post_filter": {
    "term": {
      "value": 1
    }
  }
}

Note the search result inner_hits contains both doc 1 and 2, but I'm expecting to see only doc 1 because the post_filter does not match doc 2.

Metadata

Metadata

Assignees

Labels

:Search/SearchSearch-related issues that do not fall into other categories>bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions