Skip to content

Commit

Permalink
Treat nil values as empty predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
acerbusace committed Oct 30, 2024
1 parent 0e5352a commit dfdbd15
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def process_filter_hash(bool_node, filter_hash, field_path)
# `nil` filter predicates should be ignored, so we can safely `compact` them out.
# It also is simpler to handle them once here instead of the different branches
# below having to be aware of possible `nil` predicates.
expression = expression.compact if expression.is_a?(::Hash)

case filter_node_interpreter.identify_node_type(field_or_op, expression)
when :empty
# This is an "empty" filter predicate and we can ignore it.
Expand Down Expand Up @@ -313,6 +311,9 @@ def process_list_count_expression(bool_node, expression, field_path)
# While we index an explicit count of 0, the count field will be missing from documents indexed before
# the list field was defined on the ElasticGraph schema. To properly match those documents, we need to
# convert this into an OR (using `any_of`) to also match documents that lack the field entirely.
expression = expression.compact
return if expression.empty?

unless excludes_zero?(expression)
expression = {schema_names.any_of => [
expression,
Expand Down

0 comments on commit dfdbd15

Please sign in to comment.