Skip to content

Commit

Permalink
vectorstore[patch]: Fix in exists operator. Was working as null (#51)
Browse files Browse the repository at this point in the history
So... yeah I f***ed up. But this is the fix.

The $exists was working as the $null, but the rename implies also
changing how the bool value is interpreted:

$exists: True (there is a tag, I don't care the value)
$exists: False (no tag in there)

ref: #40
  • Loading branch information
MartinGotelli authored May 18, 2024
1 parent 30ed6b2 commit 9912f54
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion langchain_postgres/vectorstores.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ def _handle_field_filter(
self.EmbeddingStore.cmetadata,
field,
)
return ~condition if filter_value else condition
return condition if filter_value else ~condition
else:
raise NotImplementedError()

Expand Down
8 changes: 4 additions & 4 deletions tests/unit_tests/fixtures/filtering_test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,19 @@
TYPE_6_FILTERING_TEST_CASES = [
# These involve the special operator $exists
(
{"happiness": {"$exists": True}},
{"happiness": {"$exists": False}},
[],
),
(
{"happiness": {"$exists": False}},
{"happiness": {"$exists": True}},
[1, 2, 3],
),
(
{"sadness": {"$exists": True}},
{"sadness": {"$exists": False}},
[3],
),
(
{"sadness": {"$exists": False}},
{"sadness": {"$exists": True}},
[1, 2],
),
]

0 comments on commit 9912f54

Please sign in to comment.