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

Add flag to ignore synonym token filter exceptions due to analyzer processing #30968

Closed
jtreher opened this issue May 30, 2018 · 6 comments
Closed
Labels
>enhancement :Search Relevance/Analysis How text is split into tokens Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@jtreher
Copy link

jtreher commented May 30, 2018

ElasticSearch 6.0 introduced a breaking change in the way the synonym token filter behaves in custom analyzers. The tokenizer of the analyzer and the tokenfilters preceding the synonym token filter in the analyzer will be applied to each synonym. If a synonym is removed as a result of applying them, it will throw, causing index creation to fail.

I propose that a flag be added to index settings on the synonym token filter settings to simply ignore the error that is thrown or do some other check to prevent throwing. This will allow those of us with complex synonym strategies to be flexible with our usage of synonyms with the full understanding that some synonyms will be ignored in some analyzers.

The main use case here is that we have a thousands of synonyms managed by a content team. We emit a single synonyms config file for configuration that is used in many custom analyzers for many variations on text fields. This strategy has worked very well for us. Coupling the validity of a synonym to a specific analyzer requires a specific synonym configuration per analyzer in addition to a non-technical team having a full understanding of elasticsearch analyzers, both of which are obtrusive.

Example:

Take the synonym &,and

The ampersand will be eliminated by the standard tokenizer used in custom analyzer A which will throw causing the index creation to throw. However, that's a synonym that is useful in a different custom analyzer, B, that uses the whitespace tokenizer where the & is preserved.

Reference:

https://discuss.elastic.co/t/why-the-synonym-filter-change-in-6-0/133740

#27481

https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking_60_analysis_changes.html

@jimczi jimczi added the :Search Relevance/Analysis How text is split into tokens label May 30, 2018
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search-aggs

@jimczi
Copy link
Contributor

jimczi commented Jun 4, 2018

We discussed internally and agreed that's something we'd like to support.
It will require a fork of the synonym parser in Lucene to add the lenient option. I marked the issue as adopt me for now and will come back to it if it's not already taken.

@jtreher
Copy link
Author

jtreher commented Jun 4, 2018

@jimczi Thanks, that's great news.

@byronvoorbach
Copy link
Contributor

Big +1 here

@sohaibiftikhar
Copy link
Contributor

Just as an update I am working on this and should have a patch by next week.

@mayya-sharipova mayya-sharipova removed the help wanted adoptme label Jun 22, 2018
sohaibiftikhar added a commit to sohaibiftikhar/elasticsearch that referenced this issue Jul 3, 2018
mayya-sharipova pushed a commit that referenced this issue Jul 10, 2018
* Added lenient flag for synonym-tokenfilter.

Relates to #30968

* added docs for synonym-graph-tokenfilter

-- Also made lenient final
-- changed from !lenient to lenient == false

* Changes after review (1)

-- Renamed to ElasticsearchSynonymParser
-- Added explanation for ElasticsearchSynonymParser::add method
-- Changed ElasticsearchSynonymParser::logger instance to static

* Added lenient option for WordnetSynonymParser

-- also added more documentation

* Added additional documentation

* Improved documentation
mayya-sharipova pushed a commit that referenced this issue Jul 13, 2018
* Added lenient flag for synonym-tokenfilter.

Relates to #30968

* added docs for synonym-graph-tokenfilter

-- Also made lenient final
-- changed from !lenient to lenient == false

* Changes after review (1)

-- Renamed to ElasticsearchSynonymParser
-- Added explanation for ElasticsearchSynonymParser::add method
-- Changed ElasticsearchSynonymParser::logger instance to static

* Added lenient option for WordnetSynonymParser

-- also added more documentation

* Added additional documentation

* Improved documentation

(cherry picked from commit 88c270d)
@sohaibiftikhar
Copy link
Contributor

@mayya-sharipova This can be closed now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Relevance/Analysis How text is split into tokens Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

No branches or pull requests

7 participants