Background information
In the information explosion era, users often need to quickly find the information they need from massive amounts of data. Online literature databases, e-commerce product catalogs, and ever-growing multimedia libraries all rely on efficient search systems to help users locate content that interests them. As data volumes keep growing, traditional keyword-based search no longer meets the need for both precision and speed. Vector search addresses this by encoding text, images, audio, and other data types into mathematical vectors and searching in vector space. Systems can then capture deeper semantic meaning and return more accurate, relevant results.
This topic walks you through building your image search application using OceanBase's vector search technology.
Architecture
The application stores an image library as vectors in the database. In the UI, users upload the image they want to search with. The application converts that image into a vector, looks up similar vectors in the database, and returns the results. Matching images are shown on the UI.

Prerequisites
You have deployed OceanBase V4.3.3 or later and created a MySQL-compatible tenant. For more information about deploying an OceanBase cluster, see Deployment overview.
The MySQL-compatible tenant has
INSERTandSELECTprivileges. For more information about how to configure privileges, see Grant direct privileges.You have created a database. For more information about how to create a database, see Create a database.
The vector search feature is enabled for the database. For more information about the vector search feature, see Perform fast vector search by using SQL.
obclient> ALTER SYSTEM SET ob_vector_memory_limit_percentage = 30;You have prepared the images you need. If you don’t have enough for testing, you can use image datasets from major open-source sites.
You have installed Python 3.9 or later.
You have installed Poetry.
python3 -m ensurepip python3 -m pip install poetry
Build your image search application
Clone the code repository
git clone https://github.com/ob-labs/image-search.git
cd image-search
Install dependencies
poetry install
Set environment variables
cp .env.example .env
# Update the database settings in .env.
vi .env
Set the values in .env:
HF_ENDPOINT=https://hf-mirror.com
DB_HOST="127.0.0.1" ## Tenant IP
DB_PORT="2881" ## Port
DB_USER="root@test" ## Tenant and username
DB_NAME="test" ## Database name
DB_PASSWORD="" ## Tenant user password
Start the image search app
poetry run streamlit run --server.runOnSave false image_search_ui.py
You should see output like this:
Collecting usage statistics. To deactivate, set browser.gatherUsageStats to false.
You can now view your Streamlit app in your browser.
Local URL: http://localhost:8501
Network URL: http://xxx.xxx.xxx.xxx:8501
External URL: http://xxx.xxx.xxx.xxx:8501
Application demo
Prepare some images and put them in a folder on your server. In the UI, open Image loading configuration and set Image loading directory to the absolute path of that folder on the server, then click Load images.
If you do not have enough images for testing, you can use image datasets from major open-source sites.

Online demo
Besides building the app yourself, you can try the Animal Image Search online demo by logging in.