Wrong results depended by field name


#1

elasticsearch 2.1.1,

index:
"_source":{"env" : {"flash": 1 }, "index_name" : "2016-01", "user" : { "geo" : { "country" : "ZZ" } } }

curl -XPOST http://127.0.0.1:9200/test/_search?pretty=1 -d' { "query" : { "bool": { "filter": { "term" : { "env.flash" : 1 } } } } }
return some results,

but request
curl -XPOST http://127.0.0.1:9200/test/_search?pretty=1 -d' { "query" : { "bool": { "filter": { "term" : { "user.geo.country" : "ZZ" } } } } }
or
curl -XPOST http://127.0.0.1:9200/test/_search?pretty=1 -d' { "query" : { "bool": { "filter": { "index_name" : "2016-01" } } } }

return empty results. Why ?


(Ivan Brusic) #2

If you are using the standard analyzer, string fields are lowercased (among
other things). A term query requires an exact match, so an uppercase term
such as "ZZ", while not match a field that uses the standard analyzer.
"2016-01" is probably split into two tokens.

Either make the fields as non-analyzed or use a query that analyzes the
terms, such as a match query. It depends on your use case.

Ivan


(system) #3