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

**URL:** <https://discuss.elastic.co/t/synonyms-and-or-synonym-graph-for-mapping-product-names-to-other-names/267678>\
**Category:** Elasticsearch\
**Created:** [March 18, 2021, 2:05pm UTC](https://discuss.elastic.co/t/synonyms-and-or-synonym-graph-for-mapping-product-names-to-other-names/267678 "2021-03-18T14:05:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Robert\_SL](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/robert_sl/32/85761_2.png) [@Robert\_SL](https://discuss.elastic.co/u/Robert_SL)\
**Post date:** [March 18, 2021, 2:05pm UTC](https://discuss.elastic.co/t/synonyms-and-or-synonym-graph-for-mapping-product-names-to-other-names/267678/1 "2021-03-18T14:05:56Z")

</div>

(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:

```auto
     "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

```auto
     "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?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 15, 2021, 2:06pm UTC](https://discuss.elastic.co/t/synonyms-and-or-synonym-graph-for-mapping-product-names-to-other-names/267678/2 "2021-04-15T14:06:50Z")

</div>

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