# Exact phrase match with special characters '.' and ':'

**URL:** <https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402>\
**Category:** Elasticsearch\
**Created:** [June 4, 2018, 10:43am UTC](https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402 "2018-06-04T10:43:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Santhosh\_ic](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@Santhosh\_ic](https://discuss.elastic.co/u/Santhosh_ic)\
**Post date:** [June 4, 2018, 10:43am UTC](https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402/1 "2018-06-04T10:43:23Z")

</div>

Hi,

I want to match "command. Id:", exactly in 'Message'.  
I have tried this,  
{  
"query": {  
"match\_phrase": {  
"Message": {  
"query": "command. id:",  
"slop": 0  
}  
}  
}  
}  
However, this matches "Command ID" and "command ID" as well. How to achieve matching the exact phrase "command. id:". Do I need to create a custom analzyer?

---

<div class="post-metadata">

**Author:** ![tdasch](https://avatars.discourse-cdn.com/v4/letter/t/58f4c7/32.png) [@tdasch](https://discuss.elastic.co/u/tdasch)\
**Post date:** [June 4, 2018, 3:17pm UTC](https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402/2 "2018-06-04T15:17:23Z")

</div>

Hey Santhosh,

Would it be possible for you to show your mappings? If not take a look yourself and see how your `Message` field is mapped. If it isn't mapped as a `keyword` or `not_analyzed` then it is being run through an analyzer. By default `text` is run through the standard analyzer. Check out [this link](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html) which explains why a term query, or match\_phrase in your case, can fail to match what you intended. Hope this helps!

---

<div class="post-metadata">

**Author:** ![Santhosh\_ic](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@Santhosh\_ic](https://discuss.elastic.co/u/Santhosh_ic)\
**Post date:** [June 6, 2018, 9:37am UTC](https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402/3 "2018-06-06T09:37:08Z")

</div>

Thanks Thomas for quick reply. Message is an analyzed field, hence it is not matching exact phrase.

---

<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:** [July 4, 2018, 9:39am UTC](https://discuss.elastic.co/t/exact-phrase-match-with-special-characters-and/134402/4 "2018-07-04T09:39:09Z")

</div>

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