# Multi words synonyms with tokens between the synonym's parts

**URL:** <https://discuss.elastic.co/t/multi-words-synonyms-with-tokens-between-the-synonyms-parts/287518>\
**Category:** Elasticsearch\
**Created:** [October 24, 2021, 7:19pm UTC](https://discuss.elastic.co/t/multi-words-synonyms-with-tokens-between-the-synonyms-parts/287518 "2021-10-24T19:19:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olaph](https://avatars.discourse-cdn.com/v4/letter/o/a4c791/32.png) [@Olaph](https://discuss.elastic.co/u/Olaph)\
**Post date:** [October 24, 2021, 7:19pm UTC](https://discuss.elastic.co/t/multi-words-synonyms-with-tokens-between-the-synonyms-parts/287518/1 "2021-10-24T19:19:56Z")

</div>

Hi,

given, that I have following synonyms configuration:

"želvárium,aquaterrarium for turtles"  
_(želvárium is czech short-term for aquarium for turtles)_

**Is there a way that allowes me to match a document with following title when searching "želvárium"?**

"pacific aquaterrarium **50x25x19cm** for **water** turtles"

With the settings below, I can match only "pacific aquaterrarium for turtles" - there is a problem with the tokens "50x25x19cm" and "water" between "aquaterrarium" and "for turtles".

Setting for this example:

```auto
PUT /syntest
{
  "settings": {
    "index": {
      "analysis": {
        "analyzer": {
          "my_synonyms": {
            "tokenizer": "standard",
            "filter": [
                "my_synonym_graph"
            ]
          }
        },
        "filter": {
          "my_synonym_graph": {
            "type": "synonym_graph",
            "lenient": true,
            "synonyms": [
              "želvárium,aquaterrarium for turtles"
            ]
          }
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "title": {
         "type": "text",
         "search_analyzer": "my_synonyms"
      }
    }
  }  
}

POST /syntest/_doc
{
  "title": "pacific aquaterrarium 50x25x19cm for water turtles"
}

GET /syntest/_search
{
  "query" : {
    "match": {
      "title": {
        "query": "želvárium",
        "analyzer": "my_synonyms"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![Olaph](https://avatars.discourse-cdn.com/v4/letter/o/a4c791/32.png) [@Olaph](https://discuss.elastic.co/u/Olaph)\
**Post date:** [October 24, 2021, 10:41pm UTC](https://discuss.elastic.co/t/multi-words-synonyms-with-tokens-between-the-synonyms-parts/287518/3 "2021-10-24T22:41:03Z")

</div>

Looks like one possible solution is to use match\_phrase with slop parameter.  
In this case:

```auto
GET /syntest/_search
{
  "query" : {
    "match_phrase": {
      "title": {
        "query": "želvárium",
        "analyzer": "my_synonyms",
        "slop": 2
       }
    }
  }
}

```

would allow to ignore those two tokens [50x25x19cm] and [water] and return the desired document.  
Not sure if this is the right way hot to solve it.

---

<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:** [November 21, 2021, 10:41pm UTC](https://discuss.elastic.co/t/multi-words-synonyms-with-tokens-between-the-synonyms-parts/287518/4 "2021-11-21T22:41:18Z")

</div>

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