# How to properly handle multi term with stop words syonyms expansion?

**URL:** <https://discuss.elastic.co/t/how-to-properly-handle-multi-term-with-stop-words-syonyms-expansion/179269>\
**Category:** Elasticsearch\
**Created:** [May 1, 2019, 11:54pm UTC](https://discuss.elastic.co/t/how-to-properly-handle-multi-term-with-stop-words-syonyms-expansion/179269 "2019-05-01T23:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EFJunior](https://avatars.discourse-cdn.com/v4/letter/e/77aa72/32.png) [@EFJunior](https://discuss.elastic.co/u/EFJunior)\
**Post date:** [May 1, 2019, 11:54pm UTC](https://discuss.elastic.co/t/how-to-properly-handle-multi-term-with-stop-words-syonyms-expansion/179269/1 "2019-05-01T23:54:34Z")

</div>

I have the following synonym expansion :

**suco =\> suco, refresco, bebida de soja**

What i want is to tokenize the search this way:

Search for "suco de laranja" would be tokenized to ["suco", "laranja", "refresco", "bebida de soja"].

But i'm getting it tokenized to ["suco", "laranja", "refresco", "bebida", "soja"].

Consider that the " **de**" word is a stop word. And i want it to be ignored on the query like "bebida de laranja" becomes ["bebida", "laranja"]. But i don't want it to be considered on the synonym tokenization so "bebida de soja" still stays as one token "bebida de soja".

my settings :

```
{
    "settings":{
        "analysis":{
            "filter":{
                "synonym_br":{
                    "type":"synonym",
                    "synonyms":[
                        "suco => suco, refresco, bebida de soja"
                    ]
                },
                "brazilian_stop":{
                    "type":"stop",
                    "stopwords":"_brazilian_"
                }
            },
            "analyzer":{
                "synonyms":{
                    "filter":[
                        "synonym_br",
                        "lowercase",
                        "brazilian_stop",
                        "asciifolding"
                    ],
                    "type":"custom",
                    "tokenizer":"standard"
                }
            }
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [May 3, 2019, 10:08am UTC](https://discuss.elastic.co/t/how-to-properly-handle-multi-term-with-stop-words-syonyms-expansion/179269/2 "2019-05-03T10:08:40Z")

</div>

> [@EFJunior](#):
>
> i want it to be ignored on the query like "bebida de laranja" becomes ["bebida", "laranja"]. But i don't want it to be considered on the synonym tokenization so "bebida de soja" still stays as one token "bebida de soja".

This is what using [dedicated search\_analyzer](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html) settings in the mappings are used for. Keeping the stopwords at index time might lead to other issues down the road though, so you'd certainly do some experimentations on your own. But the flexibility is there.

---

<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:** [May 31, 2019, 10:12am UTC](https://discuss.elastic.co/t/how-to-properly-handle-multi-term-with-stop-words-syonyms-expansion/179269/3 "2019-05-31T10:12:37Z")

</div>

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