Skip to content

Commit

Permalink
Fix != queries returning null fields for elasticsearch
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-evs committed May 7, 2021
1 parent 75beeee commit d810c1a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion optimade/filtertransformers/elasticsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ def _query_op(self, quantity, op, value, nested=None):
return Q(query_type, **{field: value})

if op == "!=":
return ~Q( # pylint: disable=invalid-unary-operand-type
# != queries must also include an existence check
# Note that for MongoDB, `$exists` will include null-valued fields,
# where as in ES `exists` excludes them.
return ~Q(
query_type, **{field: value}
) & Q( # pylint: disable=invalid-unary-operand-type
"exists", field=field
)

def _has_query_op(self, quantities, op, predicate_zip_list):
Expand Down

0 comments on commit d810c1a

Please sign in to comment.