Commit 1505f5d
authored
Fix null numeric filter conditions (#164)
Ensures that the Num class correctly handles 0 as a valid value. This PR
modifies the `__str__` method to check if the value is `None` explicitly
instead of using a condition that treats 0 as false.
Context:
```
Q: Is there a way possible to set the filter to a num 0. Below is the client query,
filter_conditions: FilterExpression = ((Tag("doc_base_id") == doc_base.id) &
(Tag("file_id") == file_id) &
(Num("chunk_number") == chunk_num))
When I instantiate the query with a non-zero chunk_number, the generated query looks as expected and the result only contains the requested chunk:
[doc_base.id](http://doc_base.id/)
'AIGuildDemo'
file_id
'e9ffbac9ff6f67cc'
chunk_num
1
str(filter_conditions)
'((@doc_base_id:{AIGuildDemo} @file_id:{e9ffbac9ff6f67cc}) @chunk_number:[1 1])'
However, when I set chunk_num to 0, chunk_number gets left out of the query entirely, and the result of the query is all chunks with that doc_base_id and file_id:
[doc_base.id](http://doc_base.id/)
'AIGuildDemo'
file_id
'e9ffbac9ff6f67cc'
chunk_num
0
str(filter_conditions)
'(@doc_base_id:{AIGuildDemo} @file_id:{e9ffbac9ff6f67cc})'
Based on a look through redisvl documentation, it seems that this issue might be related to this feature where passing “None” will drop the filter
Is there way way to use redisvl to filter entries where chunk_number is 0?
```1 parent 1c7d2a0 commit 1505f5d
File tree
3 files changed
+19
-2
lines changed- redisvl/query
- tests
- integration
- unit
3 files changed
+19
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
375 | 375 | | |
376 | 376 | | |
377 | 377 | | |
378 | | - | |
| 378 | + | |
379 | 379 | | |
380 | | - | |
381 | 380 | | |
382 | 381 | | |
383 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
400 | 400 | | |
401 | 401 | | |
402 | 402 | | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
285 | 285 | | |
286 | 286 | | |
287 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
0 commit comments