You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Search queries that utilize filter expressions return incorrect results if some keys have fields that others do not.
From my testing, it appears that if an expression references a field name that not all keys have, the keys that do not have it are completely omitted from the results, even if the expression contains a null-check condition.
To Reproduce SET USER 1 FIELD teamId 1 FIELD optionalId 999 POINT 0 0 SET USER 2 FIELD teamId 1 POINT 0 0 SCAN USER
Observe that both keys are returned.
SCAN USER WHEREIN teamId 1 1
Observe that both keys are returned.
SCAN USER WHEREIN teamId 1 1 WHERE '!optionalId || optionalId == 999' SCAN USER WHEREIN teamId 1 1 WHERE '!!!optionalId || optionalId == 999' SCAN USER WHEREIN teamId 1 1 WHERE 'optionalId == 0 || optionalId == 999' SCAN USER WHEREIN teamId 1 1 WHERE '1 == 1 || optionalId == 999'
Observe that in all cases, only USER 1 is returned.
Also notice that even though 1 == 1 is always true, since USER 2 does not have the optionalId field, it is omitted from the results.
Expected behavior
Expressions should evaluate !<field> (or <field> == 0) to true, if the field is not present. This behavior already exists in non-expression queries, for example: SCAN USER WHEREIN teamId 1 1 WHEREIN optionalId 2 0 999
Keys should not be omitted from the results if they do not contain the fields referenced in the filter expression.
The text was updated successfully, but these errors were encountered:
I just pushed a fix. It seems that Tile38 was treating non-existent fields as undefined. This is how the expr library and javascript works, but Tile38 should be treating them as zeros instead.
Describe the bug
Search queries that utilize filter expressions return incorrect results if some keys have fields that others do not.
From my testing, it appears that if an expression references a field name that not all keys have, the keys that do not have it are completely omitted from the results, even if the expression contains a null-check condition.
Although I believe this is related to https://github.com/tidwall/expr, I am filing the issue here as it is more relevant to Tile38.
To Reproduce
SET USER 1 FIELD teamId 1 FIELD optionalId 999 POINT 0 0
SET USER 2 FIELD teamId 1 POINT 0 0
SCAN USER
Observe that both keys are returned.
SCAN USER WHEREIN teamId 1 1
Observe that both keys are returned.
SCAN USER WHEREIN teamId 1 1 WHERE '!optionalId || optionalId == 999'
SCAN USER WHEREIN teamId 1 1 WHERE '!!!optionalId || optionalId == 999'
SCAN USER WHEREIN teamId 1 1 WHERE 'optionalId == 0 || optionalId == 999'
SCAN USER WHEREIN teamId 1 1 WHERE '1 == 1 || optionalId == 999'
Observe that in all cases, only USER 1 is returned.
Also notice that even though
1 == 1
is always true, since USER 2 does not have theoptionalId
field, it is omitted from the results.Expected behavior
!<field>
(or<field> == 0
) to true, if the field is not present. This behavior already exists in non-expression queries, for example:SCAN USER WHEREIN teamId 1 1 WHEREIN optionalId 2 0 999
The text was updated successfully, but these errors were encountered: