Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,8 @@ def _filter_value_compatible(field: VectorStoreField, value: Any) -> bool:
field.type_ is None
or (field.type_ == "str" and isinstance(value, str))
or (field.type_ == "bool" and type(value) is bool)
or (field.type_ == "int" and type(value) is int)
or (field.type_ == "float" and type(value) in (int, float))
# Cosmos stores every JSON number as a double, so 2 and 2.0 compare equal.
or (field.type_ in ("int", "float") and type(value) in (int, float))
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,21 @@ async def test_full_batch_item_size_and_json_preflight() -> None:
),
(Filter("count", "eq", True), "false", []),
(Filter("count", "ne", True), 'IS_DEFINED(c["count"])', []),
(
Filter("count", "eq", 2.0),
'(IS_DEFINED(c["count"]) AND NOT IS_NULL(c["count"]) AND c["count"] = @filter_0)',
[2.0],
),
(
Filter("count", "ne", 2.0),
'(IS_DEFINED(c["count"]) AND (IS_NULL(c["count"]) OR c["count"] != @filter_0))',
[2.0],
),
(
Filter("count", "gt", 1.5),
'(IS_DEFINED(c["count"]) AND NOT IS_NULL(c["count"]) AND c["count"] > @filter_0)',
[1.5],
),
(
Filter("count", "gt", 1),
'(IS_DEFINED(c["count"]) AND NOT IS_NULL(c["count"]) AND c["count"] > @filter_0)',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,11 @@ async def test_disposable_vector_database_crud_filter_and_search() -> None:
}
assert await default_collection.get(filter=Filter("count", "eq", True)) == []
assert await default_collection.get(filter=Filter("active", "eq", 1)) == []
assert [item["key"] for item in await default_collection.get(filter=Filter("count", "eq", 2.0))] == ["two"]
assert {item["key"] for item in await default_collection.get(filter=Filter("count", "ne", 2.0))} == {
"one",
"three",
}
not_value = FilterGroup("not", [Filter("optional", "eq", "value")])
assert {item["key"] for item in await default_collection.get(filter=not_value)} == {"one", "three"}

Expand Down
Loading