haystack
haystack copied to clipboard
BM25 support with MongoDB is broken with Haystack v1.24.0
Describe the bug Like this issue BM25 support with Weaviate got broken with Haystack v1.11.0+, it seems that MongoDB Document Store can no longer be used with the BM25 node
Error message When you try to use MongoDBAtlasDocumentStore in Haystack v1.24.0 with a BM25 node you will see the following error:
Expected behavior BM25 nodes should work with MongoDB
To Reproduce
from haystack.document_stores import MongoDBAtlasDocumentStore
from haystack.pipelines import DocumentSearchPipeline
from haystack.nodes import BM25Retriever
import os
document_store = MongoDBAtlasDocumentStore(
mongo_connection_string=f"mongodb+srv://{os.getenv('MONGO_USER')}:{os.getenv('MONGO_PASS')}@{os.getenv('MONGO_URL')}",
database_name=os.getenv("MONGO_DB"),
collection_name="embeddings",
vector_search_index="uuid",
embedding_dim=384
)
retriever = BM25Retriever(document_store)
pipeline = DocumentSearchPipeline(retriever=retriever)
result = pipeline.run(
query="test",
params={
"Retriever": {
"top_k": 10,
}
}
)
FAQ Check
- [ ] Have you had a look at our new FAQ page?
System:
- OS: Ubuntu, Python 3.10.7
- GPU/CPU:
- Haystack version (commit or version number): v1.24.0
- DocumentStore: MongoDBAtlasDocumentStore
- Reader:
- Retriever: BM25