diff --git a/elasticgraph-graphql/lib/elastic_graph/graphql/filtering/filter_interpreter.rb b/elasticgraph-graphql/lib/elastic_graph/graphql/filtering/filter_interpreter.rb index e8dbfa57..1de266e6 100644 --- a/elasticgraph-graphql/lib/elastic_graph/graphql/filtering/filter_interpreter.rb +++ b/elasticgraph-graphql/lib/elastic_graph/graphql/filtering/filter_interpreter.rb @@ -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. @@ -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,