Filter records from RetrievalQA chain

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

i have stored documents to vector db as

and i am using code as

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

qa_chain = RetrievalQA.from_chain_type(llm=llm,
retriever=vectorstore.as_retriever(search_kwargs={‘k’: 4}),
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.

can I pass multiple where conditions on different properties
country equal USA
currency equal USD

in single where_filter dictionary?

Sure thing!

Here is the docs for that:

Let me know if this helps :slight_smile:

By the way, since this thread, a new integration for Langchain + Weaviate was released:

This new integration uses Weaviate python v4 client, and delivers way more performance than the previous v3 version.