Navigation Menu

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

Fix cross_fields type on multi_match query with synonyms #21638

Merged
merged 2 commits into from Nov 28, 2016
Merged

Fix cross_fields type on multi_match query with synonyms #21638

merged 2 commits into from Nov 28, 2016

Conversation

jimczi
Copy link
Contributor

@jimczi jimczi commented Nov 17, 2016

This change fixes the cross_fields type of the multi_match query when synonyms are involved.
Since 2.x the Lucene query parser creates SynonymQuery for words that appear at the same position.
For simple term query the CrossFieldsQueryBuilder expands the term to all requested fields and creates a BlendedTermQuery.
This change adds the same mechanism for SynonymQuery which otherwise are not expanded to all requested fields.
As a side note I wonder if we should not replace the BlendedTermQuery with the SynonymQuery. They have the same purpose and behave similarly.

Fixes #21633

@jimczi jimczi added :Search/Search Search-related issues that do not fall into other categories >bug v2.4.3 v5.0.2 v6.0.0-alpha1 review labels Nov 17, 2016
@jpountz
Copy link
Contributor

jpountz commented Nov 18, 2016

As a side note I wonder if we should not replace the BlendedTermQuery with the SynonymQuery.

BlendedTermQuery does a bit more as it also works across fields. However, when the field is the same, I agree we should use SynonymQuery all the time.

This change fixes the cross_fields type of the multi_match query when synonyms are involved.
Since 2.x the Lucene query parser creates SynonymQuery for words that appear at the same position.
For simple term query the CrossFieldsQueryBuilder expands the term to all requested fields and creates a BlendedTermQuery.
This change adds the same mechanism for SynonymQuery which otherwise are not expanded to all requested fields.
As a side note I wonder if we should not replace the BlendedTermQuery with the SynonymQuery. They have the same purpose and behave similarly.

Fixes #21633
@jimczi
Copy link
Contributor Author

jimczi commented Nov 22, 2016

@jpountz I pushed a change that keeps the SynonymQuery if a single field is involved and builds a BlendedTermQuery when multiple fields are provided. Can you take a look ?

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

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

LGTM

@jimczi jimczi added v5.2.0 and removed v5.0.2 labels Nov 28, 2016
@jimczi jimczi merged commit 69f35aa into elastic:master Nov 28, 2016
@jimczi jimczi deleted the cross_fields_synonyms branch November 28, 2016 13:14
jimczi added a commit that referenced this pull request Nov 28, 2016
* Fix cross_fields type on multi_match query with synonyms

This change fixes the cross_fields type of the multi_match query when synonyms are involved.
Since 2.x the Lucene query parser creates SynonymQuery for words that appear at the same position.
For simple term query the CrossFieldsQueryBuilder expands the term to all requested fields and creates a BlendedTermQuery.
This change adds the same mechanism for SynonymQuery which otherwise are not expanded to all requested fields.
As a side note I wonder if we should not replace the BlendedTermQuery with the SynonymQuery. They have the same purpose and behave similarly.

Fixes #21633

* Fallback to SynonymQuery for blended terms on a single field
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search/Search Search-related issues that do not fall into other categories v2.4.3 v5.2.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ES 5.0.X synonyms bug with multi-match/cross_fields
2 participants