LlamaIndex Vector-Stores Integration: Oceanbase
OceanBase Database is a distributed relational database. It is developed entirely by Ant Group. The OceanBase Database is built on a common server cluster. Based on the Paxos protocol and its distributed structure, the OceanBase Database provides high availability and linear scalability.
OceanBase currently has the ability to store vectors. Users can easily perform the following operations with SQL:
- Create a table containing vector type fields;
- Create a vector index table based on the HNSW algorithm;
- Perform vector approximate nearest neighbor queries;
- ...
Limitations
The vector storage capability of OceanBase is still being enhanced, and currently has the following limitations:
- Cosine vector distance support depends on the OceanBase version. If cosine is not supported, use inner product or Euclidean distance instead (Euclidean is the default).
- It should be noted that
OceanBasecurrently only supports post-filtering (i.e., filtering based on metadata after performing an approximate nearest neighbor search).
Install dependencies
We use pyobvector to integrate OceanBase vector store into LlamaIndex.
So it is necessary to install it with pip install pyobvector before starting.
Setup OceanBase
We recommend using Docker to deploy OceanBase:
docker run --name=ob433 -e MODE=slim -p 2881:2881 -d oceanbase/oceanbase-ce:4.3.3.0-100000142024101215
Usage
%pip install llama-index-vector-stores-oceanbase
%pip install llama-index
# choose dashscope as embedding and llm model, your can also use default openai or other model to test
%pip install llama-index-embeddings-dashscope
%pip install llama-index-llms-dashscope
from llama_index.vector_stores.oceanbase import OceanBaseVectorStore
from pyobvector import ObVecClient
client = ObVecClient()
client.perform_raw_text_sql(
"ALTER SYSTEM ob_vector_memory_limit_percentage = 30"
)
# Initialize OceanBaseVectorStore
oceanbase = OceanBaseVectorStore(
client=client,
dim=1536,
drop_old=True,
normalize=True,
include_sparse=False,
include_fulltext=False,
)
Sparse / Fulltext / Hybrid Search
Enable sparse and fulltext support at initialization:
oceanbase = OceanBaseVectorStore(
client=client,
dim=1536,
drop_old=True,
normalize=True,
include_sparse=True,
include_fulltext=True,
)
Use VectorStoreQueryMode for sparse, fulltext, or hybrid search. Sparse and fulltext
queries are passed via keyword arguments:
from llama_index.core.vector_stores.types import (
VectorStoreQuery,
VectorStoreQueryMode,
)
# sparse search
q = VectorStoreQuery(mode=VectorStoreQueryMode.SPARSE, similarity_top_k=5)
result = oceanbase.query(q, sparse_query={0: 1.0, 10: 0.5})
# fulltext search
q = VectorStoreQuery(
mode=VectorStoreQueryMode.TEXT_SEARCH, query_str="oceanbase"
)
result = oceanbase.query(q)
# hybrid search
q = VectorStoreQuery(
mode=VectorStoreQueryMode.HYBRID,
query_embedding=[...],
query_str="oceanbase",
similarity_top_k=5,
)
result = oceanbase.query(q, sparse_query={0: 1.0})
Metadata
Release files for llama-index-vector-stores-oceanbase 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_vector_stores_oceanbase-0.5.0.tar.gz | 12.9 kB | Without provenance | Details for llama_index_vector_stores_oceanbase-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_vector_stores_oceanbase-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_vector_stores_oceanbase-0.5.0-py3-none-any.whl |
Total release size: 25.6 kB
Release files / llama_index_vector_stores_oceanbase-0.5.0.tar.gz
| Download URL | llama_index_vector_stores_oceanbase-0.5.0.tar.gz |
|---|---|
| Size | 12.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaf1d04f6f694dbb12058981a84cf2cf544184e5ee5c5b400b8778b4e53807ce
|
|
BLAKE2b-256 checksum How to use checksums |
5de9a2caaccc048836059c26fb358fc9d7d576c64b827eab30c2dfc046ae6a5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_vector_stores_oceanbase-0.5.0-py3-none-any.whl
| Download URL | llama_index_vector_stores_oceanbase-0.5.0-py3-none-any.whl |
|---|---|
| Size | 12.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
06c76695301fe345a786876140af8814227d1dc2bba7dc0123d1f4a038a80d66
|
|
BLAKE2b-256 checksum How to use checksums |
1e82acd925392eb91aac1cf18231a9729f3c462a75a1bd3d77fadd14c07daf81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-vector-stores-oceanbase 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.