[docs] Update couchbase provider, vector store & features list (#31719)

This commit is contained in:
Nithish Raghunandanan 2025-07-05 19:34:48 +02:00 committed by GitHub
parent b26d2250ba
commit 8bdb1de006
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 265 additions and 86 deletions

View File

@ -18,14 +18,79 @@ See a [usage example](/docs/integrations/vectorstores/couchbase).
```python ```python
from langchain_couchbase import CouchbaseSearchVectorStore from langchain_couchbase import CouchbaseSearchVectorStore
import getpass
# Constants for the connection
COUCHBASE_CONNECTION_STRING = getpass.getpass(
"Enter the connection string for the Couchbase cluster: "
)
DB_USERNAME = getpass.getpass("Enter the username for the Couchbase cluster: ")
DB_PASSWORD = getpass.getpass("Enter the password for the Couchbase cluster: ")
# Create Couchbase connection object
from datetime import timedelta
from couchbase.auth import PasswordAuthenticator
from couchbase.cluster import Cluster
from couchbase.options import ClusterOptions
auth = PasswordAuthenticator(DB_USERNAME, DB_PASSWORD)
options = ClusterOptions(auth)
cluster = Cluster(COUCHBASE_CONNECTION_STRING, options)
# Wait until the cluster is ready for use.
cluster.wait_until_ready(timedelta(seconds=5))
vector_store = CouchbaseSearchVectorStore(
cluster=cluster,
bucket_name=BUCKET_NAME,
scope_name=SCOPE_NAME,
collection_name=COLLECTION_NAME,
embedding=my_embeddings,
index_name=SEARCH_INDEX_NAME,
)
# Add documents
texts = ["Couchbase is a NoSQL database", "LangChain is a framework for LLM applications"]
vectorstore.add_texts(texts)
# Search
query = "What is Couchbase?"
docs = vectorstore.similarity_search(query)
``` ```
API Reference: [CouchbaseSearchVectorStore](https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html#module-langchain_couchbase.vectorstores.search_vector_store)
## Document loader ## Document loader
See a [usage example](/docs/integrations/document_loaders/couchbase). See a [usage example](/docs/integrations/document_loaders/couchbase).
```python ```python
from langchain_community.document_loaders.couchbase import CouchbaseLoader from langchain_community.document_loaders.couchbase import CouchbaseLoader
connection_string = "couchbase://localhost" # valid Couchbase connection string
db_username = (
"Administrator" # valid database user with read access to the bucket being queried
)
db_password = "Password" # password for the database user
# query is a valid SQL++ query
query = """
SELECT h.* FROM `travel-sample`.inventory.hotel h
WHERE h.country = 'United States'
LIMIT 1
"""
loader = CouchbaseLoader(
connection_string,
db_username,
db_password,
query,
)
docs = loader.load()
``` ```
## LLM Caches ## LLM Caches
@ -56,6 +121,7 @@ set_llm_cache(
) )
``` ```
API Reference: [CouchbaseCache](https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html#langchain_couchbase.cache.CouchbaseCache)
### CouchbaseSemanticCache ### CouchbaseSemanticCache
Semantic caching allows users to retrieve cached prompts based on the semantic similarity between the user input and previously cached inputs. Under the hood it uses Couchbase as both a cache and a vectorstore. Semantic caching allows users to retrieve cached prompts based on the semantic similarity between the user input and previously cached inputs. Under the hood it uses Couchbase as both a cache and a vectorstore.
@ -90,6 +156,8 @@ set_llm_cache(
) )
``` ```
API Reference: [CouchbaseSemanticCache](https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html#langchain_couchbase.cache.CouchbaseSemanticCache)
## Chat Message History ## Chat Message History
Use Couchbase as the storage for your chat messages. Use Couchbase as the storage for your chat messages.
@ -109,3 +177,5 @@ message_history = CouchbaseChatMessageHistory(
message_history.add_user_message("hi!") message_history.add_user_message("hi!")
``` ```
API Reference: [CouchbaseChatMessageHistory](https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html#module-langchain_couchbase.chat_message_histories)

View File

@ -28,18 +28,7 @@
"execution_count": 1, "execution_count": 1,
"id": "bec8d532-fec7-4dc7-9be3-020aa7bdb01f", "id": "bec8d532-fec7-4dc7-9be3-020aa7bdb01f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m24.1.2\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.0.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n",
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [ "source": [
"pip install -qU langchain-couchbase" "pip install -qU langchain-couchbase"
] ]
@ -61,7 +50,7 @@
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
"name": "stdin", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"Enter the connection string for the Couchbase cluster: ········\n", "Enter the connection string for the Couchbase cluster: ········\n",
@ -278,16 +267,16 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"['4a6b5252-24ca-4e48-97a9-c33211fc7736',\n", "['f125b836-f555-4449-98dc-cbda4e77ae3f',\n",
" '594a413d-761a-44f1-8f0c-6418700b198d',\n", " 'a28fccde-fd32-4775-9ca8-6cdb22ca7031',\n",
" 'fdd8461c-f4e3-4c85-af8e-7782ce4d2311',\n", " 'b1037c4b-947f-497f-84db-63a4def5080b',\n",
" '3f6a82b2-7464-4eee-b209-cbca5a236a8a',\n", " 'c7082b74-b385-4c4b-bbe5-0740909c01db',\n",
" 'df8b87ad-464e-4f83-a007-ccf5a8fa4ff5',\n", " 'a7e31f62-13a5-4109-b881-8631aff7d46c',\n",
" 'aa18502e-6fb4-4578-9c63-b9a299259b01',\n", " '9fcc2894-fdb1-41bd-9a93-8547747650f4',\n",
" '8c55a17d-5fa7-4c30-a55d-7ded0d39bf46',\n", " 'a5b0632d-abaf-4802-99b3-df6b6c99be29',\n",
" '41b68c5a-ebf5-4d7a-a079-5e32926ca484',\n", " '0475592e-4b7f-425d-91fd-ac2459d48a36',\n",
" '146ac3e0-474a-422a-b0ac-c9fee718396b',\n", " '94c6db4e-ba07-43ff-aa96-3a5d577db43a',\n",
" 'e44941e9-fb3a-4090-88a0-9ffecee3e80e']" " 'd21c7feb-ad47-4e7d-84c5-785afb189160']"
] ]
}, },
"execution_count": 8, "execution_count": 8,
@ -456,7 +445,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"* [SIM=0.553145] The weather forecast for tomorrow is cloudy and overcast, with a high of 62 degrees. [{'source': 'news'}]\n" "* [SIM=0.553112] The weather forecast for tomorrow is cloudy and overcast, with a high of 62 degrees. [{'source': 'news'}]\n"
] ]
} }
], ],
@ -466,6 +455,52 @@
" print(f\"* [SIM={score:3f}] {res.page_content} [{res.metadata}]\")" " print(f\"* [SIM={score:3f}] {res.page_content} [{res.metadata}]\")"
] ]
}, },
{
"cell_type": "markdown",
"id": "faa8ed12-989a-4cd4-90bf-6156f242f008",
"metadata": {},
"source": [
"### Filtering Results\n",
"\n",
"You can filter the search results by specifying any filter on the text or metadata in the document that is supported by the Couchbase Search service. \n",
"\n",
"The `filter` can be any valid [SearchQuery](https://docs.couchbase.com/python-sdk/current/howtos/full-text-searching-with-sdk.html#search-queries) supported by the Couchbase Python SDK. These filters are applied before the Vector Search is performed. \n",
"\n",
"If you want to filter on one of the fields in the metadata, you need to specify it using `.`\n",
"\n",
"For example, to fetch the `source` field in the metadata, you need to specify `metadata.source`.\n",
"\n",
"Note that the filter needs to be supported by the Search Index."
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "b1c4d3ac-e3d2-4cba-b765-954bf45357aa",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* The stock market is down 500 points today due to fears of a recession. [{'source': 'news'}] 0.3873019218444824\n",
"* Robbers broke into the city bank and stole $1 million in cash. [{'source': 'news'}] 0.20637212693691254\n",
"* The weather forecast for tomorrow is cloudy and overcast, with a high of 62 degrees. [{'source': 'news'}] 0.10404900461435318\n"
]
}
],
"source": [
"from couchbase import search\n",
"\n",
"query = \"Are there any concerning financial news?\"\n",
"filter_on_source = search.MatchQuery(\"news\", field=\"metadata.source\")\n",
"results = vector_store.similarity_search_with_score(\n",
" query, fields=[\"metadata.source\"], filter=filter_on_source, k=5\n",
")\n",
"for res, score in results:\n",
" print(f\"* {res.page_content} [{res.metadata}] {score}\")"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "9983e83d-efd0-4b75-80db-150e0694e822", "id": "9983e83d-efd0-4b75-80db-150e0694e822",
@ -484,7 +519,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 12, "execution_count": 13,
"id": "ffa743dc-4e89-405b-ad71-7390338889e6", "id": "ffa743dc-4e89-405b-ad71-7390338889e6",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -502,6 +537,44 @@
"print(results[0])" "print(results[0])"
] ]
}, },
{
"cell_type": "markdown",
"id": "2e01eb05-77fc-49f8-a552-8af3c5d4460c",
"metadata": {},
"source": [
"### Query by turning into retriever\n",
"\n",
"You can also transform the vector store into a retriever for easier usage in your chains. \n",
"\n",
"Here is how to transform your vector store into a retriever and then invoke the retreiever with a simple query and filter."
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "3666265a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Document(id='c7082b74-b385-4c4b-bbe5-0740909c01db', metadata={'source': 'news'}, page_content='Robbers broke into the city bank and stole $1 million in cash.')]"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"retriever = vector_store.as_retriever(\n",
" search_type=\"similarity\",\n",
" search_kwargs={\"k\": 1, \"score_threshold\": 0.5},\n",
")\n",
"filter_on_source = search.MatchQuery(\"news\", field=\"metadata.source\")\n",
"retriever.invoke(\"Stealing from the bank is a crime\", filter=filter_on_source)"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "a5e45eb2-aa97-45df-bcc5-410e9626e506", "id": "a5e45eb2-aa97-45df-bcc5-410e9626e506",
@ -529,7 +602,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 13, "execution_count": 15,
"id": "7d2e607d-6bbc-4cef-83e3-b6a28bb269ea", "id": "7d2e607d-6bbc-4cef-83e3-b6a28bb269ea",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -574,7 +647,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 14, "execution_count": 16,
"id": "dc06ba4a-8a6b-4c55-bb69-95cd92db273f", "id": "dc06ba4a-8a6b-4c55-bb69-95cd92db273f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -611,7 +684,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 15, "execution_count": 17,
"id": "fd4749e6-ef4f-4cb5-95ff-37c4fa8283d8", "id": "fd4749e6-ef4f-4cb5-95ff-37c4fa8283d8",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -648,7 +721,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 16, "execution_count": 18,
"id": "b7b47e7d-c32f-4999-bce9-3c3c3cebffd0", "id": "b7b47e7d-c32f-4999-bce9-3c3c3cebffd0",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -656,13 +729,15 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"page_content='We are cutting off Russias largest banks from the international financial system. \n", "page_content='And with 75% of adult Americans fully vaccinated and hospitalizations down by 77%, most Americans can remove their masks, return to work, stay in the classroom, and move forward safely. \n",
"\n", "\n",
"Preventing Russias central bank from defending the Russian Ruble making Putins $630 Billion “war fund” worthless. \n", "We achieved this because we provided free vaccines, treatments, tests, and masks. \n",
"\n", "\n",
"We are choking off Russias access to technology that will sap its economic strength and weaken its military for years to come. \n", "Of course, continuing this costs money. \n",
"\n", "\n",
"Tonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more.' metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}\n" "I will soon send Congress a request. \n",
"\n",
"The vast majority of Americans have used these tools and may want to again, so I expect Congress to pass it quickly.' metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}\n"
] ]
} }
], ],
@ -694,7 +769,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 17, "execution_count": 19,
"id": "7e8bf7c5-07d1-4c3f-86d7-1fa3a454dc7f", "id": "7e8bf7c5-07d1-4c3f-86d7-1fa3a454dc7f",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -702,7 +777,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"(Document(id='8616f24425b94a52af3d32d20e6ffb4b', metadata={'author': 'John Doe', 'date': '2014-01-01', 'rating': 5, 'source': '../../how_to/state_of_the_union.txt'}, page_content='In this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself.'), 0.361933544533826)\n" "(Document(id='3a90405c0f5b4c09a6646259678f1f61', metadata={'author': 'John Doe', 'date': '2014-01-01', 'rating': 5, 'source': '../../how_to/state_of_the_union.txt'}, page_content='In this Capitol, generation after generation, Americans have debated great questions amid great strife, and have done great things. \\n\\nWe have fought for freedom, expanded liberty, defeated totalitarianism and terror. \\n\\nAnd built the strongest, freest, and most prosperous nation the world has ever known. \\n\\nNow is the hour. \\n\\nOur moment of responsibility. \\n\\nOur test of resolve and conscience, of history itself.'), 0.3573387440020518)\n"
] ]
} }
], ],
@ -736,7 +811,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 18, "execution_count": 20,
"id": "dd0fe7f1-aa40-4c6f-889b-99ad5efcd88b", "id": "dd0fe7f1-aa40-4c6f-889b-99ad5efcd88b",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
@ -744,7 +819,7 @@
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"(Document(id='d9b36ef70b8942dda4db63563f51cf0f', metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}, page_content='We are cutting off Russias largest banks from the international financial system. \\n\\nPreventing Russias central bank from defending the Russian Ruble making Putins $630 Billion “war fund” worthless. \\n\\nWe are choking off Russias access to technology that will sap its economic strength and weaken its military for years to come. \\n\\nTonight I say to the Russian oligarchs and corrupt leaders who have bilked billions of dollars off this violent regime no more.'), 0.7107075545629284)\n" "(Document(id='7115a704877a46ad94d661dd9c81cbc3', metadata={'author': 'Jane Doe', 'date': '2017-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}, page_content='And with 75% of adult Americans fully vaccinated and hospitalizations down by 77%, most Americans can remove their masks, return to work, stay in the classroom, and move forward safely. \\n\\nWe achieved this because we provided free vaccines, treatments, tests, and masks. \\n\\nOf course, continuing this costs money. \\n\\nI will soon send Congress a request. \\n\\nThe vast majority of Americans have used these tools and may want to again, so I expect Congress to pass it quickly.'), 0.6898253780130769)\n"
] ]
} }
], ],
@ -764,6 +839,64 @@
"print(results[0])" "print(results[0])"
] ]
}, },
{
"cell_type": "markdown",
"id": "65f9a24e-8c67-42e9-b995-6b4137da8c36",
"metadata": {},
"source": [
"**Note** \n",
"\n",
"The hybrid search results might contain documents that do not satisfy all the search parameters. This is due to the way the [scoring is calculated](https://docs.couchbase.com/server/current/search/run-searches.html#scoring). \n",
"The score is a sum of both the vector search score and the queries in the hybrid search. If the Vector Search score is high, the combined score will be more than the results that match all the queries in the hybrid search. \n",
"To avoid such results, please use the `filter` parameter instead of hybrid search."
]
},
{
"cell_type": "markdown",
"id": "334de7ac-8fd1-42b1-856e-834508af8738",
"metadata": {},
"source": [
"### Combining Hybrid Search Query with Filters\n",
"Hybrid Search can be combined with filters to get the best of both hybrid search and the filters for results matching the requirements.\n",
"\n",
"In this example, we are checking for documents with a rating between 3 & 5 and matching the string \"independence\" in the text field."
]
},
{
"cell_type": "code",
"execution_count": 21,
"id": "a360adba-03d2-4e25-877e-438538d2ea37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(Document(id='23bb51b4e4d54a94ab0a95e72be8428c', metadata={'author': 'John Doe', 'date': '2012-01-01', 'rating': 3, 'source': '../../how_to/state_of_the_union.txt'}, page_content='And we remain clear-eyed. The Ukrainians are fighting back with pure courage. But the next few days weeks, months, will be hard on them. \\n\\nPutin has unleashed violence and chaos. But while he may make gains on the battlefield he will pay a continuing high price over the long run. \\n\\nAnd a proud Ukrainian people, who have known 30 years of independence, have repeatedly shown that they will not tolerate anyone who tries to take their country backwards.'), 0.30549919644400614)\n"
]
}
],
"source": [
"filter_text = search.MatchQuery(\"independence\", field=\"text\")\n",
"\n",
"query = \"Any mention about independence?\"\n",
"results = vector_store.similarity_search_with_score(\n",
" query,\n",
" search_options={\n",
" \"query\": {\n",
" \"min\": 3,\n",
" \"max\": 5,\n",
" \"inclusive_min\": True,\n",
" \"inclusive_max\": True,\n",
" \"field\": \"metadata.rating\",\n",
" }\n",
" },\n",
" filter=filter_text,\n",
")\n",
"\n",
"print(results[0])"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "39258571-3233-45c3-a6ad-5c3c90ea2b1c", "id": "39258571-3233-45c3-a6ad-5c3c90ea2b1c",
@ -776,43 +909,6 @@
"- [Couchbase Server](https://docs.couchbase.com/server/current/search/search-request-params.html#query-object)" "- [Couchbase Server](https://docs.couchbase.com/server/current/search/search-request-params.html#query-object)"
] ]
}, },
{
"cell_type": "markdown",
"id": "db0a1d74",
"metadata": {},
"source": [
"### Query by turning into retriever\n",
"\n",
"You can also transform the vector store into a retriever for easier usage in your chains. \n",
"\n",
"Here is how to transform your vector store into a retriever and then invoke the retreiever with a simple query and filter."
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "3666265a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[Document(id='3f6a82b2-7464-4eee-b209-cbca5a236a8a', metadata={'source': 'news'}, page_content='Robbers broke into the city bank and stole $1 million in cash.')]"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"retriever = vector_store.as_retriever(\n",
" search_type=\"similarity\",\n",
" search_kwargs={\"k\": 1, \"score_threshold\": 0.5},\n",
")\n",
"retriever.invoke(\"Stealing from the bank is a crime\", filter={\"source\": \"news\"})"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "28ab35ec", "id": "28ab35ec",
@ -832,7 +928,7 @@
"id": "80958c2b-6a67-45e6-b7f0-fd2461d75e0f", "id": "80958c2b-6a67-45e6-b7f0-fd2461d75e0f",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# Frequently Asked Questions" "## Frequently Asked Questions"
] ]
}, },
{ {
@ -840,8 +936,8 @@
"id": "4f7f9838-cc20-44bc-a72d-06f2cb6c3fca", "id": "4f7f9838-cc20-44bc-a72d-06f2cb6c3fca",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Question: Should I create the Search index before creating the CouchbaseVectorStore object?\n", "### Question: Should I create the Search index before creating the CouchbaseSearchVectorStore object?\n",
"Yes, currently you need to create the Search index before creating the `CouchbaseVectoreStore` object.\n" "Yes, currently you need to create the Search index before creating the `CouchbaseSearchVectoreStore` object.\n"
] ]
}, },
{ {
@ -849,7 +945,7 @@
"id": "3f0dbc1b-9e82-4ec3-9330-6b54de00661e", "id": "3f0dbc1b-9e82-4ec3-9330-6b54de00661e",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Question: I am not seeing all the fields that I specified in my search results. \n", "### Question: I am not seeing all the fields that I specified in my search results. \n",
"\n", "\n",
"In Couchbase, we can only return the fields stored in the Search index. Please ensure that the field that you are trying to access in the search results is part of the Search index.\n", "In Couchbase, we can only return the fields stored in the Search index. Please ensure that the field that you are trying to access in the search results is part of the Search index.\n",
"\n", "\n",
@ -865,10 +961,10 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "3702977a-2e25-48b6-b662-edd5cb94cdec", "id": "0449a2e3-59d7-4b25-b09e-a2b062fef01f",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## Question: I am unable to see the metadata object in my search results. \n", "### Question: I am unable to see the metadata object in my search results. \n",
"This is most likely due to the `metadata` field in the document not being indexed and/or stored by the Couchbase Search index. In order to index the `metadata` field in the document, you need to add it to the index as a child mapping. \n", "This is most likely due to the `metadata` field in the document not being indexed and/or stored by the Couchbase Search index. In order to index the `metadata` field in the document, you need to add it to the index as a child mapping. \n",
"\n", "\n",
"If you select to map all the fields in the mapping, you will be able to search by all metadata fields. Alternatively, to optimize the index, you can select the specific fields inside `metadata` object to be indexed. You can refer to the [docs](https://docs.couchbase.com/cloud/search/customize-index.html) to learn more about indexing child mappings.\n", "If you select to map all the fields in the mapping, you will be able to search by all metadata fields. Alternatively, to optimize the index, you can select the specific fields inside `metadata` object to be indexed. You can refer to the [docs](https://docs.couchbase.com/cloud/search/customize-index.html) to learn more about indexing child mappings.\n",
@ -879,6 +975,19 @@
"* [Couchbase Server](https://docs.couchbase.com/server/current/search/create-child-mapping.html)" "* [Couchbase Server](https://docs.couchbase.com/server/current/search/create-child-mapping.html)"
] ]
}, },
{
"cell_type": "markdown",
"id": "c9b8632e-9bce-41c8-b6aa-e527b41de9b2",
"metadata": {},
"source": [
"### Question: What is the difference between filter and search_options / hybrid queries? \n",
"Filters are [pre-filters](https://docs.couchbase.com/server/current/vector-search/pre-filtering-vector-search.html#about-pre-filtering) that are used to restrict the documents searched in a Search index. It is available in Couchbase Server 7.6.4 & higher.\n",
"\n",
"Hybrid Queries are additional search queries that can be used to tune the results being returned from the search index. \n",
"\n",
"Both filters and hybrid search queries have the same capabilites with slightly different syntax. Filters are [SearchQuery](https://docs.couchbase.com/python-sdk/current/howtos/full-text-searching-with-sdk.html#search-queries) objects while the hybrid search queries are [dictionaries](https://docs.couchbase.com/server/current/search/search-request-params.html).\n"
]
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"id": "d876b769", "id": "d876b769",
@ -886,7 +995,7 @@
"source": [ "source": [
"## API reference\n", "## API reference\n",
"\n", "\n",
"For detailed documentation of all `CouchbaseSearchVectorStore` features and configurations head to the API reference: https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html " "For detailed documentation of all `CouchbaseSearchVectorStore` features and configurations head to the [API reference](https://couchbase-ecosystem.github.io/langchain-couchbase/langchain_couchbase.html#module-langchain_couchbase.vectorstores.search_vector_store)"
] ]
} }
], ],

View File

@ -1038,17 +1038,17 @@ const FEATURE_TABLES = {
idsInAddDocuments: false, idsInAddDocuments: false,
}, },
{ {
name: "CouchbaseVectorStore", name: "CouchbaseSearchVectorStore",
link: "couchbase", link: "couchbase",
deleteById: true, deleteById: true,
filtering: true, filtering: true,
searchByVector: false, searchByVector: true,
searchWithScore: true, searchWithScore: true,
async: true, async: true,
passesStandardTests: false, passesStandardTests: false,
multiTenancy: false, multiTenancy: true,
local: true, local: true,
idsInAddDocuments: false, idsInAddDocuments: true,
}, },
{ {
name: "DatabricksVectorSearch", name: "DatabricksVectorSearch",