I use the match query search for "request.method": "GET":
{ "query": { "filtered": { "query": { "match": { "request.method": "GET" } }, "filter": { "bool": { "must": [ ...
As expected, the Match query can get the results, as shown below:
But the question is when using the Term query, there is no results.
Update the query to change the "match" to "term", and keep the other part remain the same:
{ "query": { "filtered": { "query": { "term": { "request.method": "GET" } }, "filter": { "bool": { "must": [ ...
I think the Term query is the "not analyzed" version of the Match query. As shown in above picture, there is at least one record has "request.method" equal to "GET". Why there is no results for the above-mentioned Term query? Thank you.
To better search text fields, the match query also analyzes your provided search term before performing a search. This means the match query can search text fields for analyzed tokens rather than an exact term. The term query does not analyze the search term. The term query only searches for the exact term you provide.
Term queryedit. Returns documents that contain an exact term in a provided field. You can use the term query to find documents based on a precise value such as a price, a product ID, or a username. Avoid using the term query for text fields.
In Elasticsearch, fuzzy query means the terms are not the exact matches of the index. The result is 2, but you can use fuzziness to find the correct word for a typo in Elasticsearch's fuzzy in Match Query. For 6 characters, the Elasticsearch by default will allow 2 edit distance.
Assuming you are using the Standard Analyzer GET
becomes get
when stored in the index. The source document will still have the original "GET".
The match
query will apply the same standard analyzer to the search term and will therefore match what is stored in the index. The term
query does not apply any analyzers to the search term, so will only look for that exact term in the inverted index.
To use the term query in your example, change the upper case "GET" to lower case "get" or change your mapping so the request.method field is set to not_analyzed
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With