Skip to content

Commit f28f587

Browse files
committed
Make field </<= x always match null values
This is how regular filters behave.
1 parent 5134708 commit f28f587

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/schema-generation/flex-search-filter-input-types/filter-fields.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,22 @@ export function resolveFilterField(
389389
not(new FlexSearchFieldExistsQueryNode(valueNode, analyzer))
390390
);
391391
}
392+
// field < x and field <= x should also find NULL values, because that's how it behaves in non-flexsearch case
393+
if (
394+
(filterField.operatorName === INPUT_FIELD_LT || filterField.operatorName === INPUT_FIELD_LTE) &&
395+
filterValue != null
396+
) {
397+
const isNull = new BinaryOperationQueryNode(
398+
new BinaryOperationQueryNode(valueNode, BinaryOperator.EQUAL, NullQueryNode.NULL),
399+
BinaryOperator.OR,
400+
not(new FlexSearchFieldExistsQueryNode(valueNode, analyzer))
401+
);
402+
return new BinaryOperationQueryNode(
403+
isNull,
404+
BinaryOperator.OR,
405+
filterField.resolveOperator(valueNode, literalNode, analyzer)
406+
);
407+
}
392408
if (filterField.operatorName == INPUT_FIELD_IN && Array.isArray(filterValue) && filterValue.includes(null)) {
393409
return new BinaryOperationQueryNode(
394410
filterField.resolveOperator(valueNode, literalNode, analyzer),

0 commit comments

Comments
 (0)