I confirm that I am using langchain-mongodb package
langchain-mongodb==0.1.8
The pre_filter works like a charm, is filtering the results as expected:
_search_kwargs = {"pre_filter": {"author_gender": "male"}}
qa = RetrievalQA.from_chain_type(
llm=llm,
chain_type="stuff",
retriever=vector_store.as_retriever(search_kwargs=_search_kwargs)
)
question = "List novels with authors name"
result = qa({"query": question})
print(result["result"])
Here are the novels with their respective authors' names:
1. "The Great Gatsby" by F. Scott Fitzgerald
2. "Moby-Dick" by Herman Melville
3. "The Catcher in the Rye" by J.D. Salinger
Thank you very much for your help.