Reputation: 15363
Given:
I loaded an instance into ElasticSearch which has its placeId
property set to "Foo"
.
And I run the following searches:
{
"query": {
"term": {
"placeId": {
"value": "Foo"
}
}
}
}
{
"filter": {
"term": {
"placeId": "Foo"
}
}
}
{
"query": {
"match": {
"placeId": {
"query": "Foo"
}
}
}
}
But of these three, only the third one returned a result.
Why is this? Shouldn't they all have returned a result?
Upvotes: 1
Views: 848
Reputation: 292
If u are not used an analyzer means elastic search term query and term query Filter should not support the Upper case Value. Please use "foo" in Your Query. please use this way
curl -XGET localhost:9200/index/incident/_search -d '{
"query":{
"term":{"field1":{"value":"value1"}
}}}'
but match all query is support upper and lower case. Hope it will work.
Upvotes: 0
Reputation: 52368
By default, using the standard analyzer, ES places your "Foo" in an index as "foo" (meaning, lowercased). When searching for term
, ES doesn't use an analyzer so, it is actually searching for "Foo" (exact case). Whereas, in its index the "foo" exists (because of the analyzer).
The value passed for match
instead is analyzed and ES is actually searching for "foo" in its indices, not "Foo" as it does with term
.
So, the behavior you see is normal and this is how it's supposed to work.
Here about match
:
A family of match queries that accept text/numerics/dates, analyzes it, and constructs a query out of it.
Here about term
:
Matches documents that have fields that contain a term (not analyzed).
Upvotes: 2