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

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?

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 which explains why a term query, or match_phrase in your case, can fail to match what you intended. Hope this helps!

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

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