Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that field collapsing works with field aliases. #50768

Merged
merged 1 commit into from
Jan 8, 2020

Conversation

jtibshirani
Copy link
Contributor

Backport of #50722, opening to get a full build.

Previously, the following situation would throw an error:
* A search contains a `collapse` on a particular field.
* The search spans multiple indices, and in one index the field is mapped as a
  concrete field, but in another it is a field alias.

The error occurs when we attempt to merge `CollapseTopFieldDocs` across shards.
When merging, we validate that the name of the collapse field is the same across
shards. But the name has already been resolved to the concrete field name, so it
will be different on shards where the field was mapped as an alias vs. shards
where it was a concrete field.

This PR updates the collapse field name in `CollapseTopFieldDocs` to the
original requested field, so that it will always be consistent across shards.

Note that in elastic#32648, we already made a fix around collapsing on field aliases.
However, we didn't test this specific scenario where the field was mapped as an
alias in only one of the indices being searched.
@jtibshirani jtibshirani added :Search Foundations/Mapping Index mappings, including merging and defining field types backport v7.5.2 labels Jan 8, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@jtibshirani jtibshirani merged commit 9b676b5 into elastic:7.5 Jan 8, 2020
@jtibshirani jtibshirani deleted the collapse-with-alias branch January 8, 2020 23:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Search Foundations/Mapping Index mappings, including merging and defining field types v7.5.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants