I am using a matchQuery
to query Elasticsearch in Java. Below is my query:
sourceBuilder.query(QueryBuilders.matchQuery("TransactionId_s","BulkRunTest.20Nov20201446.00"));
The field TransactionId_s
is not a keyword
. And I am expecting the matchQuery to match the exact string I have given and return the results. There should be no documents in Elasticsearch with TransactionId_s
as BulkRunTest.20Nov20201446.00
. But I am getting some results and they have the TransactionId_s
like below:
"TransactionId_s" : "BulkRunTest.17Sep20201222.00"
"TransactionId_s" : "BulkRunTest.22Sep20201450.00"
"TransactionId_s" : "BulkRunTest.20Sep20201250.00"
When I tried using a termQuery
instead of matchQuery
, I am getting 0 results, which is the expected result. I thought matchQuery
would allow me to query any field for the given value without me having to worry about tokenization. Am i wrong? And how do I resolve the issue I am seeing?
Any help would be much appreciated. Thank you.