Experience vector search with SQL
seekdb can be used from an SDK or over SQL. This topic walks you through trying vector search via SQL.
To use seekdb from an SDK instead, see Experience embedded seekdb with the Python SDK.
In this example you will:
- Deploy seekdb in client/server mode.
- Connect to seekdb.
- Create a database.
- Create a table and insert data.
- Run a vector search.
- Clean up.
Deployment options
seekdb supports several deployment options, from quick prototyping to large-scale production.
-
Embedded mode: seekdb runs as a lightweight library inside your application. Install with pip. Suited for learning, prototyping, and running on resource-constrained devices.
-
Client/server mode: Recommended for testing and production. Easy to set up and run as a standalone service.
For a full overview of deployment options, see Deployment overview.
Step 1: Deploy seekdb in client/server mode
- CentOS/RHEL
- Debian/Ubuntu
- macOS
- Docker
Prerequisites
- Your system is RPM-based. Supported distributions include:
- Anolis OS 8.x (Linux kernel 4.19 or later)
- Anolis OS 23.x (Linux kernel 6.6 or later)
- CentOS Linux 7.x and 9.x (Linux kernel 4.19 or later)
- openEuler 22.03 and 24.03 (Linux kernel 5.10.0 or later)
- At least 1 CPU core and 2 GB of available memory.
- MySQL client installed.
- Your user can run
sudo. - The
jqCLI is installed and systemd is configured as the service manager.
Deploy seekdb
-
Install seekdb.
curl -fsSL https://obbusiness-private.oss-cn-shanghai.aliyuncs.com/download-center/opensource/seekdb/seekdb_install.sh | sudo bash -
Start seekdb.
sudo systemctl start seekdb -
Check status.
sudo systemctl status seekdbWhen the status shows
Service is ready, seekdb is running.
Prerequisites
- Your system is DEB-based. Supported distributions include:
- Debian 11, 12, and 13 (Linux kernel 4.19 or later)
- Ubuntu 20.04, 22.04, and 24.04 (Linux kernel 4.19 or later)
- At least 1 CPU core and 2 GB of available memory.
- MySQL client installed.
- Your user can run
sudo. - The
jqCLI is installed and systemd is configured as the service manager.
Deploy seekdb
-
Add the seekdb repository.
echo "deb [trusted=yes] http:/mirrors.aliyun.com/oceanbase/community/stable/$(lsb_release -is | awk '{print tolower($0)}')/$(lsb_release -cs)/$(dpkg --print-architecture)/ ./" | tee /etc/apt/sources.list.d/oceanbase.list -
Install seekdb.
sudo apt update
sudo apt install seekdb -
Start seekdb.
sudo systemctl start seekdb -
Check status.
sudo systemctl status seekdbWhen the status shows
Service is ready, seekdb is running.
Prerequisites
- macOS 15 or later.
- At least 1 CPU core and 2 GB of available memory.
- MySQL client installed.
Deploy seekdb
-
Add the seekdb tap.
brew tap oceanbase/seekdb -
Install seekdb.
brew install seekdb -
Start seekdb.
seekdb-start
Prerequisites
- At least 1 CPU core and 2 GB of memory.
- Docker installed and the Docker service running.
Deploy seekdb in Docker
If Docker is installed and running, you can start seekdb with:
sudo docker run -d -p 2881:2881 oceanbase/seekdb
If pulling from Docker Hub fails, try quay.io/oceanbase/seekdb or ghcr.io/oceanbase/seekdb instead. For example: sudo docker run -d -p 2881:2881 quay.io/oceanbase/seekdb
For more details, see Deploy seekdb with Docker.
Step 2: Connect to seekdb
Connect with the MySQL client:
mysql -h127.0.0.1 -uroot -P2881 -p****** -A
Step 3: Create a database
Create a database named my_test. You can also use the default database test if you prefer.
-
Create the database.
CREATE DATABASE my_test; -
Use it.
USE my_test;
Step 4: Create a table and insert data
-
Create a table with a vector column and index.
Use the
VECTOR(dim)type for vector columns and create an index on that column. The vector index must include at leasttypeanddistance.Example: table with vector column
embeddingof dimension 3 and an HNSW index with L2 distanceCREATE TABLE t1(
id INT PRIMARY KEY,
doc VARCHAR(200),
embedding VECTOR(3),
VECTOR INDEX idx1(embedding) WITH (distance=L2, type=hnsw)
); -
Insert data.
INSERT INTO t1
VALUES (1, 'apple', '[1.2,0.7,1.1]'),
(2, 'banana', '[0.6,1.2,0.8]'),
(3, 'orange', '[1.1,1.1,0.9]'),
(4, 'carrot', '[5.3,4.8,5.4]'),
(5, 'spinach', '[4.9,5.3,4.8]'),
(6, 'tomato', '[5.2,4.9,5.1]');
Step 5: Run a vector search
Vector search takes a query vector. To find the three closest rows to the vector for "fruit" [0.9, 1.0, 0.9]:
SELECT id, doc FROM t1
ORDER BY l2_distance(embedding, '[0.9, 1.0, 0.9]')
APPROXIMATE LIMIT 3;
Example result:
+----+--------+
| id | doc |
+----+--------+
| 3 | orange |
| 2 | banana |
| 1 | apple |
+----+--------+
3 rows in set
Step 6: Clean up
To remove the example database and table:
-
Drop the table.
DROP TABLE t1; -
Drop the database.
DROP DATABASE my_test;
What's next
Explore more seekdb features and build AI applications:
- Experience hybrid search with SQL
- Experience vector search
- Experience full-text indexing
- Experience hybrid search
- Experience AI functions
- Experience semantic indexing
- Build a knowledge base desktop application based on seekdb
- Build a cultural tourism assistant with seekdb multi-model integration
- Build an image search application based on seekdb