Similarity search Filter #8063
Replies: 2 comments
-
Answer generated by a 🤖 AnswerI understand that you're having trouble figuring out what to pass in the When I use the Here's how I would use it in code: vectordb.similarity_search(query_document, k=n_results, filter={'category': 'science'}) This would return the Please keep in mind that this is just one way to use the If you find this explanation helpful and feel that it could benefit others, I encourage you to make a pull request to update the documentation. This way, other users who might have the same question can benefit from your contribution. SourcesThis response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
Beta Was this translation helpful? Give feedback.
-
Above answer should be correct, I tested filtering on metadata and had good results. You have to use a dictionary. But it only works if you have metadata in your vector... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
vectordb.similarity_search(query_document, k=n_results, filter = {...})
I have checked through documentation of chroma but didnt get any solution.
Can you please help me out filer Like what i need to pass in filter section.
This is code which i am using.
`def similarity_search(
self,
query: str,
k: int = DEFAULT_K,
filter: Optional[Dict[str, str]] = None,
**kwargs: Any,
) -> List[Document]:
"""Run similarity search with Chroma.
`
Beta Was this translation helpful? Give feedback.
All reactions