New add_synonyms_to_settings method + default_search analyzer
Description of the Change
This PR adds synonyms in a new default_analyzer, so its filter doesn't conflict with word_delimiter_graph during index time.
It still needs some tests
Closes #2877
How to test the Change
Changelog Entry
Fixed - Synonyms are now applied only during search time, fixing an incompatibility with the
word_delimiter_graphfilter.
Credits
Props @felipeelia
Moving synonyms to be applied only during search time revealed a problem with how we use "alternatives".
As per Elasticsearch docs:
Explicit mappings match any token sequence on the LHS of "=>" and replace with all alternatives on the RHS.
So, if we have shoes => sneakers, all shoes in a post will be replaced by sneakers. Right now, that replacement happens on both index and search times going unnoticed most of the time. There is one scenario where that is verifiable though:
- Empty all alternatives in the Synonyms Screen and save
- Create a post with
This is my content with shoesas content and save. It will be indexed asshoes. - Search for
shoesand see the post there - Add
shoes => sneakersas alternatives - Search for
shoesand see the post gone - Save the post again. Now
shoeswill be replaced withsneakersin the index - Search for
shoesand see the post back
To have alternatives to the way we phrase it right now, it is necessary to add the main term in the list, like shoes => sneakers, shoes.
The questions would be:
- Do we want to keep the intended behavior (hiding from the user the main term in the list of "alternatives")? In this case, the user would see
shoes => sneakersbut we would sendshoes => shoes, sneakersto Elasticsearch. - Do we want to rephrase that in a way the user can decide if that is a replacement or an alternative? In this case, it would be up to the user to decide between
shoes => sneakersorshoes => shoes, sneakers.
After some internal discussion, we will have some UX treatment on the screen to clarify to users how the feature works. Ideas so far are to rename "Primary Term" to "Search Term" and "Comma separated list of alternatives" to "Match list" or "Search rewrites".
UX deliverable created, please refer to internal channels.
Closing in favor of #3610