Python: Bug: vector store filters fail when the constant is on the left, including chained comparisons
Maintainer thường phản hồi trong vòng 3 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- python
- Lĩnh vực
- backend-api-design, databases
Hướng nghiên cứu
Start in Python’s VectorSearch._build_filter and read _FoldUnaryNumericConstants from the referenced change #14572; compare it with the filter parsers for Qdrant and Chroma. The issue proposes normalizing reversed and chained comparisons before connector parsing. Done means the three examples return the expected records on Qdrant and Chroma while existing field-left filters continue to work; an open linked pull request (#14781) indicates work is already underway.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the bug
Vector store filters fail when the constant is on the left of a comparison, and that includes Python's chained range comparison. QdrantCollection and ChromaCollection raise for all three of these, while InMemoryCollection and FaissCollection return the expected records:
await collection.search(vector=[1.0, 1.0], filter="lambda x: 2 < x.num") # expected num 3, 4, 5
await collection.search(vector=[1.0, 1.0], filter="lambda x: 3 == x.num") # expected num 3
await collection.search(vector=[1.0, 1.0], filter="lambda x: 1 <= x.num < 4") # expected num 1, 2, 3
Qdrant fails with a pydantic ValidationError (FieldCondition gets key=3, or Range gets lt="num"). Chroma fails with Expected where key to be a str, got 2.
The chained form is the one users are most likely to write. QdrantCollection._lambda_parser already splits chains into an AND (the comment there gives 1 < x < 3 as the example), but the first pair of a chain always has the constant on the left, so that path can't succeed today.
To Reproduce
A record type with an int data field num, six records with num 0 to 5, then the searches above on QdrantCollection(location=":memory:") and an ephemeral ChromaCollection. Rewriting each filter with the field on the left (x.num > 2, x.num >= 1 and x.num < 4) works on both.
Expected behavior
The same records as the field-on-the-left form, as InMemoryCollection returns today.
Additional context
Checked by running: Qdrant and Chroma fail. In-memory and FAISS work.
Read in the code but not run: the Weaviate, Pinecone, MongoDB and Azure Cosmos DB parsers also take the left operand as the field name and have no case for a constant there. Redis and Azure AI Search handle the reversed form explicitly. The SQL-based connectors may work by accident, since 2 < num is valid SQL.
Suggested fix: Normalize the tree once in VectorSearch._build_filter, next to _FoldUnaryNumericConstants from #14572, so the connector parsers stay unchanged:
- rewrite
Constant op FieldasField op' Constant, flipping</>and<=/>=and keeping==/!= - split a chained comparison
a < b < cintoa < b and b < c
in and not in with the constant on the left mean "the list field contains the value", which is a different operation, so I'd leave them as they are.
I'm happy to open a PR for this if the approach sounds right.
Platform
- Language: Python
- Source: main at b714e97
- Python 3.12, qdrant-client 1.20.0, chromadb 1.5.9
AI disclosure: found with Claude Code while comparing filter results across the Python connectors.
- Ngôn ngữ chính
- C#
- Star
- 28.8k
- Fork
- 4.9k
- Merge trung bình
- 2 ngày 17 giờ
- Pull request đã merge (30 ngày)
- 48
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/semantic-kernel
-
Python: Bug: ChatMessageContent.from_element drops AudioContent and BinaryContent into raw TextContentCó thể đã có người làm @halcyon-past đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
microsoft/semantic-kernel#14824 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Python: Bug: Redis search returns None for every field that declares a storage_name, because RETURN lists the declared nameCó thể đã có người làm @wasim-builds đã nhận 9 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/semantic-kernel#14753 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
.Net: gpt-image-1 is the default image model in the .NET OpenAI connector, and OpenAI shuts it down on October 23Có thể đã có người làm @nightcityblade đã nhận 46 ngày trước. Đang mở.NET triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
microsoft/semantic-kernel#14526 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Python: VolatileMemoryStore.get_batch and get_nearest_matches ignore with_embeddings=False (deepcopy result is discarded)Có thể đã có người làm @VANDRANKI đã nhận 48 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
microsoft/semantic-kernel#14522 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
.Net: Bug: BinaryContent does not decode the %xx escapes of a non-base64 data URICó thể đã có người làm @Laurianti đã nhận 48 ngày trước. Đang mở.NET triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/semantic-kernel#14518 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của microsoft/semantic-kernel
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Support Flux ignore rules (drift detection ignore paths) in Microsoft.KubernetesConfiguration schemaĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Azure/azure-resource-manager-schemas#3921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
text-align: justify is ignored in HTML to PDF conversionCó thể đã có người làm @PrzemyslawKlys đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 4 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
asyncapi/modelina#2709 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày