Filter records from RetrievalQA chain

How to filter records based on identifier (識別子) word in JAPANESE,

i have stored documents to vector db as
識別子「xyz」のために、モジュールは「abc」であれば、ページは「747」

and i am using code as

vectorstore = Weaviate(client, “dbname”, “final_document”)

qa_chain = RetrievalQA.from_chain_type(llm=llm,
chain_type=‘stuff’,
retriever=vectorstore.as_retriever(search_kwargs={‘k’: 4}),
return_source_documents=True,
chain_type_kwargs={‘prompt’: prompt}
)

final_document is key against which docs are stored to vector db

Hi @Abhishek_Joshi !

Is this Langchain?

If that’s the case (llamaindex and langchain sometimes have similar syntax/api) we have here a recipe that can ilustrate that:

#source_file = "brazil-wikipedia-article-text.pdf"
source_file = "netherlands-wikipedia-article-text.pdf"
where_filter = {
      "operator": "Equal",
      "path": ["source"],
      "valueText": source_file
  }

# we want our retriever to filter the results
retriever = db.as_retriever(search_kwargs={"where_filter": where_filter})

Let me know if that helps.