From 8a5807a6b4a99d79fe9d740958ffb5d692a972f1 Mon Sep 17 00:00:00 2001 From: Martin Gullbrandson <45486484+MartinHex@users.noreply.github.com> Date: Wed, 30 Oct 2024 15:15:11 +0100 Subject: [PATCH] docs: Update Milvus documentation to correctly show how to filter in similarity_search (#27723) ### Description/Issue: I had problems filtering when setting up a local Milvus db and noticed that the `filter` option in the `similarity_search` and `similarity_search_with_score` appeared to do nothing. Instead, the `expr` option should be used. The `expr` option is correctly used in the retriever example further down in the documentation. The `expr` option seems to be correctly passed on, for example [here](https://github.com/langchain-ai/langchain/blob/447c0dd2f051157a3ccdac49a8d5ca6c06ea1401/libs/community/langchain_community/vectorstores/milvus.py#L701) ### Solution: Update the documentation for the functions mentioned to show intended behavior. --------- Co-authored-by: Chester Curme --- docs/docs/integrations/vectorstores/milvus.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/integrations/vectorstores/milvus.ipynb b/docs/docs/integrations/vectorstores/milvus.ipynb index 34bda120d89aa..2cbc8d4e97362 100644 --- a/docs/docs/integrations/vectorstores/milvus.ipynb +++ b/docs/docs/integrations/vectorstores/milvus.ipynb @@ -314,7 +314,7 @@ "results = vector_store.similarity_search(\n", " \"LangChain provides abstractions to make working with LLMs easy\",\n", " k=2,\n", - " filter={\"source\": \"tweet\"},\n", + " expr='source == \"tweet\"',\n", ")\n", "for res in results:\n", " print(f\"* {res.page_content} [{res.metadata}]\")" @@ -346,7 +346,7 @@ ], "source": [ "results = vector_store.similarity_search_with_score(\n", - " \"Will it be hot tomorrow?\", k=1, filter={\"source\": \"news\"}\n", + " \"Will it be hot tomorrow?\", k=1, expr='source == \"news\"'\n", ")\n", "for res, score in results:\n", " print(f\"* [SIM={score:3f}] {res.page_content} [{res.metadata}]\")"