# How to perform exact string match query in ES

**URL:** <https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727>\
**Category:** Elasticsearch\
**Created:** [February 1, 2019, 12:01pm UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727 "2019-02-01T12:01:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![suripaleru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suripaleru/32/32286_2.png) [@suripaleru](https://discuss.elastic.co/u/suripaleru)\
**Post date:** [February 1, 2019, 12:01pm UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727/1 "2019-02-01T12:01:21Z")

</div>

How perform exact query match search operation on ES ? I tried below one but giving contains instead of matching.

GET default-2018.\*/\_search  
{  
"query": {  
"match": {  
"message": "need to find exact message"  
}  
}  
}

But here, i'm getting results with message "need to send" or "find text".. but i need documents which are having message as "need to find exact message"

---

<div class="post-metadata">

**Author:** ![Bibin\_Sebastian](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@Bibin\_Sebastian](https://discuss.elastic.co/u/Bibin_Sebastian)\
**Post date:** [February 1, 2019, 2:48pm UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727/2 "2019-02-01T14:48:03Z")

</div>

what is the type of message in your schema mapping for your index. if you explicitly set the type as `keyword`, you should get an exact match for your search.  
ref - [https://www.elastic.co/blog/strings-are-dead-long-live-strings](https://www.elastic.co/blog/strings-are-dead-long-live-strings)

---

<div class="post-metadata">

**Author:** ![suripaleru](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/suripaleru/32/32286_2.png) [@suripaleru](https://discuss.elastic.co/u/suripaleru)\
**Post date:** [February 1, 2019, 3:10pm UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727/3 "2019-02-01T15:10:44Z")

</div>

Thank you for your response. I'm using one of the Keyword field to find data from ES. ANd i got an udpated script but still this is also not work .

GET default-2018.\*/\_search  
{  
"query": {  
"query\_string" : {  
"default\_field" : "message",  
"query" : "Found valid data. Can proceed to click the link.",  
"phrase\_slop": 0  
}  
}  
}

Here, ES is giving results which are having atleast one word in any log instead of giving only exact match. How i can format above query to get only exact matching results ?

---

<div class="post-metadata">

**Author:** ![Bibin\_Sebastian](https://avatars.discourse-cdn.com/v4/letter/b/7993a0/32.png) [@Bibin\_Sebastian](https://discuss.elastic.co/u/Bibin_Sebastian)\
**Post date:** [February 2, 2019, 11:44am UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727/4 "2019-02-02T11:44:12Z")

</div>

thats strange. are you sure type for the field `message` is keyword?  
can you post your schema mapping for your index?

(how to find schema mapping for your index - [https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-mapping.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:** [March 2, 2019, 11:44am UTC](https://discuss.elastic.co/t/how-to-perform-exact-string-match-query-in-es/166727/5 "2019-03-02T11:44:18Z")

</div>

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