Skip to content

Commit 9912f54

Browse files
vectorstore[patch]: Fix in exists operator. Was working as null (#51)
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
1 parent 30ed6b2 commit 9912f54

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

langchain_postgres/vectorstores.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ def _handle_field_filter(
720720
self.EmbeddingStore.cmetadata,
721721
field,
722722
)
723-
return ~condition if filter_value else condition
723+
return condition if filter_value else ~condition
724724
else:
725725
raise NotImplementedError()
726726

tests/unit_tests/fixtures/filtering_test_cases.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,19 +226,19 @@
226226
TYPE_6_FILTERING_TEST_CASES = [
227227
# These involve the special operator $exists
228228
(
229-
{"happiness": {"$exists": True}},
229+
{"happiness": {"$exists": False}},
230230
[],
231231
),
232232
(
233-
{"happiness": {"$exists": False}},
233+
{"happiness": {"$exists": True}},
234234
[1, 2, 3],
235235
),
236236
(
237-
{"sadness": {"$exists": True}},
237+
{"sadness": {"$exists": False}},
238238
[3],
239239
),
240240
(
241-
{"sadness": {"$exists": False}},
241+
{"sadness": {"$exists": True}},
242242
[1, 2],
243243
),
244244
]

0 commit comments

Comments
 (0)