Synonyms and/or synonym graph for mapping product names to other names

(Elastic Cloud 6.8)

I have a requirement when searching for a product name to also return a different product that will replace it in the future.

For example, when the user searches for "Product ABC", I also want to return "Product D E F Extraword" but not "Product D E F".

We tried to solve this using a synonym filter, which kind of works but also returns "Product ABC" when you search for "Product D E F" because we used a mapping like the following:

     "english_synonyms": {
            "type": "synonym",
            "expand": "false",
            "synonyms": [
                  "Product D E F=>Product ABC",
                  "Product D E F,Product ABC=>Product D E F"
            ]
      }

I tried to replace this with a synonym graph token filter

     "english_synonyms": {
            "type": "synonym_graph",
            "expand": "false",
            "lenient": "true",
            "synonyms": [
              "Product D E F Extraword=>Product ABC"
            ]
          }

Which meets the requirement for searching for "Product ABC". "Product ABC" and "Product D E F Extraword" is returned, however, when searching for "Product D E F" only "Product D E F" is returned, I assume because "Product D E F Extraword" is mapped as a multi word synonym to "Product ABC"

So my question is, is this the right use of synonyms?

I have a suspicion that I should be trying to solve this by adding additional fields to the "Product D E F Extraword" document such as "alternative_name" and solving this with a search query instead. Is this a better approach? Or is there another clever technique for mapping one word to another that I am missing?

If it is the correct use of synonyms what is wrong with my configuration to achieve the requirements?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.