Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Bug
-
None
Description
Currently elasticsearch adapters ignore records which do not have the field specified in NotEqual clause, which is ideally included by elasticsearch.
Query:
SELECT* from zips WHERE name <> "NMAX"
The elasticsearch query formed for above is this :
{ "query": { "constant_score": { "filter": { "bool": { "must": { "exists": { "field": "Name" } }, "must_not": { "term": { "Name": "NMQAX" } } } } } } }
Problem : The above query ignores document which do not have Name field which is ideally included by elasticsearch but ignored due to must exists condition.
Data:
{ "_id" : "01701", "name" : "NMAX", "loc" : [ -71.42548600000001, 42.300665 ], "pop" : 65046, "state" : "MA" } { "_id" : "02154", "name" : "NORTH WALTHAM", "loc" : [ -71.236497, 42.382492 ], "pop" : 57871, "state" : "MA" } { "_id" : "02401 , "loc" : [ -71.03434799999999, 42.081571 ], "pop" : 59498, "state" : "MA" }
Expected result:
{ "_id" : "02154", "name" : "NORTH WALTHAM", "loc" : [ -71.236497, 42.382492 ], "pop" : 57871, "state" : "MA" } { "_id" : "02401", "loc" : [ -71.03434799999999, 42.081571 ], "pop" : 59498, "state" : "MA" }
Current Result:
{ "_id" : "02154", "name" : "NORTH WALTHAM", "loc" : [ -71.236497, 42.382492 ], "pop" : 57871, "state" : "MA" }
RelNode for same -
relB.not(relB.equals(relb.literal("Name"),relb.literal"NMQAX"))
Solution : Remove the exists condition from Not equals Query Expression. Elasticsearch doesn't put this condition therefore keeping queries in sync. Code
Attachments
Issue Links
- links to