Skip to content

How to test if a value is null in aggregation? #4845

Open
@rChaoz

Description

@rChaoz

How can I check if a field reference/aggregation expression is null and obtain a boolean?

  • ConditionalOperators.ifNull("field").then(false) - does not return true/false
  • ComparisonOperators.valueOf("field").equalToValue(null) - throws NPE
  • BooleanOperators.Or.or(Fields.field("field")) - also returns true if value is 0

I just want to obtain $eq: ["$field", null]. Am I missing something?

Workaround

ArrayOperators.arrayOf(List.of("null", "missing")).containsValue((DataTypeOperators.typeOf("field")));

But this results in a different query, I'd like to obtain exactly $eq: ["$field", null].

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions