# Analyzer and search\_analyzer for common tokens

**URL:** <https://discuss.elastic.co/t/analyzer-and-search-analyzer-for-common-tokens/104254>\
**Category:** Elasticsearch\
**Created:** [October 17, 2017, 1:56pm UTC](https://discuss.elastic.co/t/analyzer-and-search-analyzer-for-common-tokens/104254 "2017-10-17T13:56:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjost1988](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cjost1988/32/23116_2.png) [@cjost1988](https://discuss.elastic.co/u/cjost1988)\
**Post date:** [October 17, 2017, 1:56pm UTC](https://discuss.elastic.co/t/analyzer-and-search-analyzer-for-common-tokens/104254/1 "2017-10-17T13:56:14Z")

</div>

Hello guys,

I've an issue with a match query on a text field that contains a product title.

Product titles:

- A: `Spezial-Träger`
- B: `Träger`

If someone searches for `Spezial-Träger` only A should match since it's the most precise match you can get, because it's exactly the product the customer is searching for.

But if you enter `Träger` it should match the base product `Träger` as well as the more precise one `Spezial-Träger`.

I tried to define an `index_analyzer` which generates all possible token variations of the indexed product:  
A: `spezialtrager`, `spezial`, `trager`  
B: `trager`

Then I tried to define a `search_analyzer` which only generates the most precise token possible:  
A: `spezialtrager`  
B: `trager`

**ES \_analyze:**  
Index: "Spezial-Träger":  
{  
"tokens": [  
{  
"token": "spezialtrager",  
"start\_offset": 0,  
"end\_offset": 14,  
"type": "word",  
"position": 0  
},  
{  
"token": "spezial",  
"start\_offset": 0,  
"end\_offset": 7,  
"type": "word",  
"position": 0  
},  
{  
"token": "trager",  
"start\_offset": 8,  
"end\_offset": 14,  
"type": "word",  
"position": 1  
}  
]  
}

Search: "Spezial-Träger":  
{  
"tokens": [  
{  
"token": "spezialtrager",  
"start\_offset": 0,  
"end\_offset": 14,  
"type": "word",  
"position": 0  
}  
]  
}

As I follow the ES documentation:

- Tokens are evaluated in an specific order, different analyzers have to generate the same order of common tokens

But I don't get any match. I am lost 😃

Thanks a lot for any help.

Kind regards,  
Christian

---

<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 14, 2017, 1:56pm UTC](https://discuss.elastic.co/t/analyzer-and-search-analyzer-for-common-tokens/104254/2 "2017-11-14T13:56:15Z")

</div>

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