mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-09 13:00:34 +00:00
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](447c0dd2f0/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 <chester.curme@gmail.com>
This commit is contained in:
parent
028e0253d8
commit
8a5807a6b4
@ -314,7 +314,7 @@
|
|||||||
"results = vector_store.similarity_search(\n",
|
"results = vector_store.similarity_search(\n",
|
||||||
" \"LangChain provides abstractions to make working with LLMs easy\",\n",
|
" \"LangChain provides abstractions to make working with LLMs easy\",\n",
|
||||||
" k=2,\n",
|
" k=2,\n",
|
||||||
" filter={\"source\": \"tweet\"},\n",
|
" expr='source == \"tweet\"',\n",
|
||||||
")\n",
|
")\n",
|
||||||
"for res in results:\n",
|
"for res in results:\n",
|
||||||
" print(f\"* {res.page_content} [{res.metadata}]\")"
|
" print(f\"* {res.page_content} [{res.metadata}]\")"
|
||||||
@ -346,7 +346,7 @@
|
|||||||
],
|
],
|
||||||
"source": [
|
"source": [
|
||||||
"results = vector_store.similarity_search_with_score(\n",
|
"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",
|
")\n",
|
||||||
"for res, score in results:\n",
|
"for res, score in results:\n",
|
||||||
" print(f\"* [SIM={score:3f}] {res.page_content} [{res.metadata}]\")"
|
" print(f\"* [SIM={score:3f}] {res.page_content} [{res.metadata}]\")"
|
||||||
|
Loading…
Reference in New Issue
Block a user