ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

New add_synonyms_to_settings method + default_search analyzer

Open felipeelia opened this issue 3 years ago • 3 comments

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_graph filter.

Credits

Props @felipeelia

felipeelia avatar Jul 27 '22 18:07 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:

  1. Empty all alternatives in the Synonyms Screen and save
  2. Create a post with This is my content with shoes as content and save. It will be indexed as shoes.
  3. Search for shoes and see the post there
  4. Add shoes => sneakers as alternatives
  5. Search for shoes and see the post gone
  6. Save the post again. Now shoes will be replaced with sneakers in the index
  7. Search for shoes and 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:

  1. 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 => sneakers but we would send shoes => shoes, sneakers to Elasticsearch.
  2. 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 => sneakers or shoes => shoes, sneakers.

felipeelia avatar Jul 29 '22 19:07 felipeelia

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".

felipeelia avatar Aug 03 '22 12:08 felipeelia

UX deliverable created, please refer to internal channels.

nickolas-kola avatar Aug 11 '22 15:08 nickolas-kola

Closing in favor of #3610

felipeelia avatar Aug 22 '23 18:08 felipeelia