docs/integrations/vector-db-integrations/couchbase.mdx
This is the implementation of the Couchbase Vector store data handler for MindsDB.
Couchbase is an open-source, distributed multi-model NoSQL document-oriented database software package optimized for interactive applications. These applications may serve many concurrent users by creating, storing, retrieving, aggregating, manipulating, and presenting data.
Before proceeding, ensure the following prerequisites are met:
In order to make use of this handler and connect to a Couchbase server in MindsDB, the following syntax can be used. Note, that the example uses the default travel-sample bucket which can be enabled from the couchbase UI with pre-defined scope and documents.
CREATE DATABASE couchbase_vectorsource
WITH
engine='couchbasevector',
parameters={
"connection_string": "couchbase://localhost",
"bucket": "travel-sample",
"user": "admin",
"password": "password",
"scope": "inventory"
};
This handler is implemented using the couchbase library, the Python driver for Couchbase.
The required arguments to establish a connection are as follows:
connection_string: the connection string for the endpoint of the Couchbase serverbucket: the bucket name to use when connecting with the Couchbase serveruser: the user to authenticate with the Couchbase serverpassword: the password to authenticate the user with the Couchbase serverscope: scopes are a level of data organization within a bucket. If omitted, will default to _defaultNote: The connection string expects either the couchbases:// or couchbase:// protocol.
<Tip> If you are using Couchbase Capella, you can find the connection_string under the Connect tab. It will also be required to whitelist the machine(s) that will be running MindsDB and database credentials will need to be created for the user. These steps can also be taken under the Connect tab. </Tip>Now, you can use the established connection to create a collection (or table in the context of MindsDB) in Couchbase and insert data into it:
Now, you can use the established connection to create a collection (or table in the context of MindsDB) in Couchbase and insert data into it:
CREATE TABLE couchbase_vectorsource.test_embeddings (
SELECT embeddings
FROM mysql_datasource.test_embeddings
);
You can query your collection (table) as shown below:
SELECT *
FROM couchbase_vectorsource.test_embeddings;
To filter the data in your collection (table) by metadata, you can use the following query:
SELECT *
FROM couchbase_vectorsource.test_embeddings
WHERE id = "some_id";
To perform a vector search, the following query can be used:
SELECT *
FROM couchbase_vectorsource.test_embeddings
WHERE embeddings = (
SELECT embeddings
FROM mysql_datasource.test_embeddings
LIMIT 1
);
You can delete documents using DELETE just like in SQL.
DELETE FROM couchbase_vectorsource.test_embeddings
WHERE `metadata.test` = 'test1';
To drop the connection, use this command
DROP DATABASE couchbase_vectorsource;