In-memory filter evaluation of 'in'/'not in' on list-valued meta fields diverges from OpenSearch/Elasticsearch terms semantics
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #13313 de @Naeemeh146 — cerrado sin fusionar
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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!
- Lenguaje dominante
- Python
- Estrellas
- 27.2k
- Forks
- 3.5k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 254
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de deepset-ai/haystack
-
feat: `ByteStream.from_file_path` should keep the file path in `meta`Posiblemente ocupada @pinjun99 la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
deepset-ai/haystack#14081 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
BlockingConfirmationStrategy ignores an empty argument replacementPosiblemente ocupada @sjrl la tomó hace 6 días. AbiertoP1
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
deepset-ai/haystack#13863 · 2 comentarios · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
CSVToDocument row mode fails on CR-separated CSV inputPosiblemente ocupada @julian-risch la tomó hace 66 días. AbiertoP3
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
deepset-ai/haystack#13022 · 1 comentario · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
CSVToDocument row mode drops a real extra_columns field on ragged rowsQuizá libre de nuevo Un pull request para esta issue se cerró sin fusionarse. Abiertohandled internally P3
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
deepset-ai/haystack#12994 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
CSVDocumentCleaner deletes a row that says N/A, and both CSV components empty those cellsPosiblemente ocupada @michaelkillgta la tomó hace 72 días. AbiertoP3
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
deepset-ai/haystack#12784 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de deepset-ai/haystack
Issues similares
-
Test: to_hijri() accepts datetime.datetime and uses only the date partPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertogood first issue
Dificultad 1/5 Menos de una hora Aptitud para principiantes 95/100
omarelshamy25x/shamy-hijri#63 · 3 comentarios ·
Los mantenedores suelen responder en 1 día
-
polish
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
521xueweihan/HelloGitHub#4729 ·
-
[Bug]: Score parser reads parts of scientific notation as valid scoresPosiblemente ocupada @AshutoshSingh840 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
UKGovernmentBEIS/control-arena#992 ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
mvalentsev/awesome-free-ai-coding#70 ·
Los mantenedores suelen responder en 1 día