How to perform exact string match query in ES

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"

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

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 ?

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)

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