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

Make sure that field collapsing supports field aliases. #32648

Merged
merged 1 commit into from
Aug 7, 2018

Conversation

jtibshirani
Copy link
Contributor

This component of the search request wasn't covered by the original field alias PR.

Addresses #32623.

@jtibshirani jtibshirani added >bug :Search Foundations/Mapping Index mappings, including merging and defining field types v7.0.0 v6.4.0 v6.5.0 labels Aug 6, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;

public class FieldCollapseIT extends ESIntegTestCase {
Copy link
Contributor Author

@jtibshirani jtibshirani Aug 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into creating a unit test, but for just adding this single case, it was a lot cleaner/ simpler to write an integration test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a rest test ? We have rest-api-spec/src/main/resources/rest-api-spec/test/search/110_field_collapsing.yml already so maybe add a case there ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find REST tests more difficult to work with in terms of debugging, so I've been preferring Java integration tests unless I'm actually testing the REST spec. I'm happy to switch this over though, if writing a REST test is more standard.

Copy link
Contributor

@jimczi jimczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left one comment, thanks @jtibshirani

import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoFailures;

public class FieldCollapseIT extends ESIntegTestCase {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about a rest test ? We have rest-api-spec/src/main/resources/rest-api-spec/test/search/110_field_collapsing.yml already so maybe add a case there ?

@jtibshirani jtibshirani force-pushed the collapse-on-field-alias branch 2 times, most recently from e128456 to ffb967d Compare August 7, 2018 19:02
@jtibshirani
Copy link
Contributor Author

Thanks @jimczi, I think it's ready for another look.

@jtibshirani
Copy link
Contributor Author

@elasticmachine run packaging tests

@jtibshirani jtibshirani merged commit d7183f8 into elastic:master Aug 7, 2018
@jtibshirani jtibshirani deleted the collapse-on-field-alias branch August 7, 2018 23:20
tvernum added a commit that referenced this pull request Aug 8, 2018
Disables the rest tests introduced in
    b83354e.
    Make sure that field collapsing supports field aliases. (#32648)

These tests need setup that is not compatible with older versions and
cause BWC tests to fail
tvernum added a commit that referenced this pull request Aug 8, 2018
Disables the rest tests introduced in
    b83354e.
    Make sure that field collapsing supports field aliases. (#32648)

These tests need setup that is not compatible with older versions and
cause BWC tests to fail
jtibshirani added a commit to jtibshirani/elasticsearch that referenced this pull request Jan 8, 2020
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 added a commit that referenced this pull request Jan 8, 2020
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 #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 added a commit that referenced this pull request Jan 8, 2020
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 #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 added a commit that referenced this pull request Jan 8, 2020
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 #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.
SivagurunathanV pushed a commit to SivagurunathanV/elasticsearch that referenced this pull request Jan 23, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Foundations/Mapping Index mappings, including merging and defining field types v6.4.0 v6.5.0 v7.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants