Experience hybrid search with SQL
seekdb can be used from an SDK or over SQL. This topic walks you through trying hybrid 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 hybrid search.
- Tune search with boost.
- 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 scalar columns, a vector column, and full-text indexes so you can try full-text search with filters and hybrid search.
CREATE TABLE doc_table(
c1 INT,
vector VECTOR(3),
query VARCHAR(255),
content VARCHAR(255),
VECTOR INDEX idx1(vector) WITH (distance=l2, type=hnsw, lib=vsag),
FULLTEXT INDEX idx2(query),
FULLTEXT INDEX idx3(content)
)
ORGANIZATION HEAP; -
Insert data.
INSERT INTO doc_table VALUES
(1, '[1,2,3]', "hello world", "seekdb Elasticsearch database"),
(2, '[1,2,1]', "hello world, what is your name", "seekdb database"),
(3, '[1,1,1]', "hello world, how are you", "seekdb mysql database"),
(4, '[1,3,1]', "real world, where are you from", "postgres mysql database"),
(5, '[1,3,2]', "real world, how old are you", "redis mysql database"),
(6, '[2,1,1]', "hello world, where are you from", "starrocks seekdb database");
Step 5: Run hybrid search
-
Set the search parameters.
SET @parm = '{
"query": {
"query_string": {
"fields": ["query", "content"],
"query": "hello oceanbase"
}
},
"knn" : {
"field": "vector",
"k": 5,
"query_vector": [1,2,3]
}
}'; -
Run the query.
SELECT json_pretty(DBMS_HYBRID_SEARCH.SEARCH('doc_table', @parm));Example result:
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json_pretty(DBMS_HYBRID_SEARCH.SEARCH('doc_table', @parm)) |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [
{
"c1": 1,
"query": "hello world",
"_score": 1.3716216216216217,
"vector": "[1,2,3]",
"content": "seekdb Elasticsearch database"
},
{
"c1": 2,
"query": "hello world, what is your name",
"_score": 0.6646586312048193,
"vector": "[1,2,1]",
"content": "seekdb database"
},
{
"c1": 3,
"query": "hello world, how are you",
"_score": 0.6593354613375797,
"vector": "[1,1,1]",
"content": "seekdb mysql database"
},
{
"c1": 5,
"query": "real world, how old are you",
"_score": 0.41421356,
"vector": "[1,3,2]",
"content": "redis mysql database"
},
{
"c1": 6,
"query": "hello world, where are you from",
"_score": 0.3503184713375797,
"vector": "[2,1,1]",
"content": "starrocks seekdb database"
},
{
"c1": 4,
"query": "real world, where are you from",
"_score": 0.30901699,
"vector": "[1,3,1]",
"content": "postgres mysql database"
}
] |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set
Step 6: Tune search with boost
You can use the boost parameter to change the balance between full-text and vector search. For example, to favor keyword match over semantic similarity, increase the full-text boost.
-
Set the search parameters.
SET @parm = '{
"query": {
"query_string": {
"fields": ["query", "content"],
"query": "hello oceanbase",
"boost": 2.0
}
},
"knn" : {
"field": "vector",
"k": 5,
"query_vector": [1,2,3],
"boost": 1.0
}
}'; -
Run the query.
SELECT json_pretty(DBMS_HYBRID_SEARCH.SEARCH('doc_table', @parm));Example result:
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| json_pretty(DBMS_HYBRID_SEARCH.SEARCH('doc_table', @parm)) |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| [
{
"c1": 1,
"query": "hello world",
"_score": 1.7432432432432434,
"vector": "[1,2,3]",
"content": "seekdb Elasticsearch database"
},
{
"c1": 3,
"query": "hello world, how are you",
"_score": 1.0096539326751595,
"vector": "[1,1,1]",
"content": "seekdb mysql database"
},
{
"c1": 2,
"query": "hello world, what is your name",
"_score": 0.9959839324096386,
"vector": "[1,2,1]",
"content": "seekdb database"
},
{
"c1": 6,
"query": "hello world, where are you from",
"_score": 0.7006369426751594,
"vector": "[2,1,1]",
"content": "starrocks seekdb database"
},
{
"c1": 5,
"query": "real world, how old are you",
"_score": 0.41421356,
"vector": "[1,3,2]",
"content": "redis mysql database"
},
{
"c1": 4,
"query": "real world, where are you from",
"_score": 0.30901699,
"vector": "[1,3,1]",
"content": "postgres mysql database"
}
] |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set
Adjusting boost changes how much keyword match and semantic similarity affect the final order. Increase query_string.boost to favor keywords; increase knn.boost to favor semantic similarity.
Step 7: Clean up
To remove the example database and table:
-
Drop the table.
DROP TABLE doc_table; -
Drop the database.
DROP DATABASE my_test;
What's next
Explore more seekdb features and build AI applications:
- Experience vector 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