# Searching tokenized field containing "." returns unexpected results

**URL:** <https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425>\
**Category:** Elasticsearch\
**Created:** [July 26, 2019, 11:43am UTC](https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425 "2019-07-26T11:43:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nverrill](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@nverrill](https://discuss.elastic.co/u/nverrill)\
**Post date:** [July 26, 2019, 11:43am UTC](https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425/1 "2019-07-26T11:43:17Z")

</div>

I have a newly tokenized field of type text for domains. It is a reverse path hierarchy tokenizer on the "."  
So a field like "[adservice.google.com](http://adservice.google.com)" becomes the following 3 tokens:  
com  
[google.com](http://google.com)  
[adservice.google.com](http://adservice.google.com)

I assumed I could then search the field, from say kibana, with the syntax:  
+Domain:google.com  
But it finds all fields with a "com" token, so I'll get [microsoft.com](http://microsoft.com) and [amazon.com](http://amazon.com), etc.  
I tried encasing in quotes and escaping the ".", but neither helped.

However:  
A single wildcard, or regex both work as expected:  
+Domain:google?com  
+Domain:/google.com/

Can someone point me to an explanation of why the original syntax returns unexpected results?  
+Domain:google.com

Edit: elastic stack 6.3.2

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [August 2, 2019, 2:02pm UTC](https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425/2 "2019-08-02T14:02:56Z")

</div>

It happens because you apply the same tokenization on the search side as well. So basically when you search for `+Domain:google.com` it is translated into `+Synonym(domain:com domain:google.com)`. To avoid this you need to use a different analyzer for searching that uses keyword tokenizer instead of reverse path hierarchy tokenizer.

---

<div class="post-metadata">

**Author:** ![nverrill](https://avatars.discourse-cdn.com/v4/letter/n/7c8e57/32.png) [@nverrill](https://discuss.elastic.co/u/nverrill)\
**Post date:** [August 5, 2019, 1:13pm UTC](https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425/3 "2019-08-05T13:13:10Z")

</div>

Wow, I didn't know that search\_analyzer was even a thing. Thank you for that pointer!  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-analyzer.html)

---

<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:** [September 2, 2019, 1:21pm UTC](https://discuss.elastic.co/t/searching-tokenized-field-containing-returns-unexpected-results/192425/4 "2019-09-02T13:21:31Z")

</div>

Closed on September 2, 2019, 1:21pm UTC

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