In-memory filter evaluation of 'in'/'not in' on list-valued meta fields diverges from OpenSearch/Elasticsearch terms semantics
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
- #13313 @Naeemeh146 による — マージされずにクローズ
評価
この issue はまだ評価されていません。
説明
Describe the bug
For a document whose meta field holds a list, the in-memory filter evaluation applies in as a Python membership test (the whole list must be an element of the filter values), while the OpenSearch and Elasticsearch integrations translate in to a terms query (match when any element of the field is in the filter values). The same filter returns opposite results depending on the document store, with no warning.
Reproduction
from haystack import Document
from haystack.document_stores.in_memory import InMemoryDocumentStore
docs = [
Document(id="1", content="a", meta={"tags": ["a"]}),
Document(id="2", content="b", meta={"tags": ["z"]}),
]
store = InMemoryDocumentStore()
store.write_documents(docs)
print(store.filter_documents({"field": "tags", "operator": "in", "value": ["a", "b"]}))
# [] <- doc 1 not matched: ["a"] in ["a", "b"] is False in Python
print(store.filter_documents({"field": "tags", "operator": "not in", "value": ["a", "b"]}))
# [doc 1, doc 2] <- the exact opposite of what terms semantics give
The OpenSearch integration converts the same filter to {"terms": {"tags": ["a", "b"]}} (haystack-core-integrations, opensearch/filters.py). Under OpenSearch terms semantics, doc 1 matches the in filter and is excluded by the not in filter - the inverse of the in-memory result. The Elasticsearch integration does the same.
Why this matters
A common workflow is to prototype a pipeline on InMemoryDocumentStore (or test components with the in-memory retriever) and then deploy against OpenSearch/Elasticsearch. A retrieval filter that excludes every document with multi-valued tags in testing starts returning them in production, and not in flips from keeping everything to dropping exactly the documents the prototype kept. Nothing in the filter or the logs hints at the change.
Possible directions
- Evaluate
in/not inas overlap (any element in common) for list-valued fields indocument_matches_filter, aligning the in-memory reference implementation with the term-based stores, or - Raise a
FilterErrorwheninis used against a list-valued field so the divergence is loud instead of silent, or - Document the difference explicitly; the pgvector integration already exposes
array_contains/array_overlapsas distinct operators, so an explicit overlap operator in core would also work.
Environment
- haystack-ai 3.3.0
- opensearch-haystack (filters.py
in->terms) checked from haystack-core-integrations main - Python 3.10
👋 Hello there! This issue will be handled internally and isn't open for external contributions. If you'd like to contribute, please take a look at issues labeled contributions welcome or good first issue. We'd really appreciate it!
- 主要言語
- Python
- スター
- 27.2k
- フォーク
- 3.5k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 254
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
deepset-ai/haystack のほかの issue
-
feat: `ByteStream.from_file_path` should keep the file path in `meta`対応中かも @pinjun99 が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
deepset-ai/haystack#14081 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
BlockingConfirmationStrategy ignores an empty argument replacement対応中かも @sjrl が 6 日前に担当しました。 オープンP1
難易度 1/5 1〜3時間 初心者へのやさしさ 82/100
deepset-ai/haystack#13863 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
CSVToDocument row mode fails on CR-separated CSV input対応中かも @julian-risch が 66 日前に担当しました。 オープンP3
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
deepset-ai/haystack#13022 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
CSVToDocument row mode drops a real extra_columns field on ragged rows再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンhandled internally P3
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
deepset-ai/haystack#12994 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
CSVDocumentCleaner deletes a row that says N/A, and both CSV components empty those cells対応中かも @michaelkillgta が 72 日前に担当しました。 オープンP3
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
deepset-ai/haystack#12784 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
deepset-ai/haystack の issue をすべて見る
似ている issue
-
Test: to_hijri() accepts datetime.datetime and uses only the date part対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンgood first issue
難易度 1/5 1時間未満 初心者へのやさしさ 95/100
omarelshamy25x/shamy-hijri#63 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
polish
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scores対応中かも @AshutoshSingh840 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
UKGovernmentBEIS/control-arena#992 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
mvalentsev/awesome-free-ai-coding#70 ·
メンテナーはふだん 1 日以内に返信