pyxvector
pyxvector is a thin, dependency-light Python HTTP client for Xvector — a vector database service that speaks Milvus REST v2 style APIs. It covers collections, partitions, indexes, aliases, entities (insert / upsert / delete / get / query), vector search, hybrid search, RBAC (users / roles / privileges) and bulk-import jobs.
Supported Python versions
pyxvector supports Python 3.9 – 3.13 (any Python >= 3.9):
| Python version | Supported |
|---|---|
| 3.9 | ✅ |
| 3.10 | ✅ |
| 3.11 | ✅ |
| 3.12 | ✅ |
| 3.13 | ✅ |
Dependencies
pyxvector only requires one runtime dependency:
| Package | Version constraint |
|---|---|
| httpx | >=0.27,<1 |
Install from PyPI:
pip install pyxvector
Quick start
from pyxvector import XvectorClient
client = XvectorClient(uri="http://127.0.0.1:19530", token="root:Xvector")
# 1. Create a collection with an Int64 primary key and a 4-dim float vector field
client.create_collection(
"demo",
schema={
"fields": [
{"name": "id", "dataType": "Int64", "isPrimaryKey": True},
{"name": "vector", "dataType": "FloatVector", "dim": 4},
]
},
)
# 2. Create an index and load the collection into memory
client.create_index("demo", "vector", index_type="FLAT", metric_type="L2")
client.load_collection("demo")
# 3. Insert rows
client.insert("demo", [{"id": 1, "vector": [0.1, 0.2, 0.3, 0.4]}])
# 4. Search immediately after write (refresh=True forces read-after-write consistency;
# otherwise writes become visible within ~10s)
hits = client.search(
"demo",
[[0.1, 0.2, 0.3, 0.4]],
anns_field="vector",
limit=3,
refresh=True,
)
print(hits)
# 5. Clean up
client.drop_collection("demo")
client.close()
XvectorClient is also a context manager:
from pyxvector import XvectorClient
with XvectorClient(uri="http://127.0.0.1:19530", token="root:Xvector") as client:
print(client.list_collections())
Multi-database
client.using_database("my_db") # subsequent calls target the "my_db" database
Error handling
All server-side errors are raised as XvectorApiError (a subclass of XvectorError), carrying the numeric code and message returned by the server:
from pyxvector import XvectorClient, XvectorApiError
client = XvectorClient(uri="http://127.0.0.1:19530", token="root:Xvector")
try:
client.describe_collection("not_exist")
except XvectorApiError as e:
print(e.code, e.message)
API overview
All methods map 1:1 to the Milvus REST v2 style endpoints (/v2/vectordb/...) exposed by Xvector.
| Area | Methods |
|---|---|
| Collection | create_collection, drop_collection, describe_collection, has_collection, list_collections, rename_collection, load_collection, release_collection, get_load_state, get_collection_stats |
| Partition | create_partition, drop_partition, has_partition, list_partitions, load_partitions, release_partitions, get_partition_stats |
| Index | create_index, describe_index, drop_index, list_indexes |
| Alias | create_alias, drop_alias, alter_alias, describe_alias, list_aliases |
| Entities | insert, upsert, delete, get, query |
| Search | search, hybrid_search, search_after_write |
| Database | create_database, drop_database, list_databases, describe_database |
| User | create_user, drop_user, list_users, describe_user, update_password, grant_role, revoke_role |
| Role | create_role, drop_role, list_roles, describe_role, grant_privilege, revoke_privilege |
| Import | create_import_job, get_import_progress, list_import_jobs |
| Helpers | wait_loaded, wait_import_complete, close |
More examples
Hybrid search with RRF rerank
client.hybrid_search(
"demo",
search=[
{"data": [[0.1, 0.2, 0.3, 0.4]], "annsField": "vector", "limit": 10},
],
rerank={"strategy": "rrf", "params": {"k": 60}},
limit=5,
)
Filtered query
rows = client.query("demo", filter="id >= 1", output_fields=["id"], limit=100, refresh=True)
Bulk import from files
job = client.create_import_job("demo", files=["/data/batch1.json"], format="json")
client.wait_import_complete(job["jobId"])
Wait until a collection is loaded
client.load_collection("demo")
client.wait_loaded("demo", timeout=30)
Project links
- Project home / Xvector server: https://github.com/lxl0928/Xvector
- pyxvector source: https://github.com/lxl0928/pyxvector
- Issue tracker: https://github.com/lxl0928/Xvector/issues
- PyPI: https://pypi.org/project/pyxvector/
GitHub statistics
Live stats for the Xvector repository:
Maintainers
- Li Xiaolong (Timilong) — timilong928@gmail.com — github.com/lxl0928
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyxvector-1.0.0.tar.gz.
File metadata
- Download URL: pyxvector-1.0.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
376b80c922596b43b191505fcd08ae5b17c33ffa61501a0b7b4653fc3830ab0f
|
|
| MD5 |
9b384bf2a21e8548758892b9039336f0
|
|
| BLAKE2b-256 |
26ec6fb7585f935a6eb19f7bce6c57126091ab31ad4d499a411e91dac8fdb332
|
File details
Details for the file pyxvector-1.0.0-py3-none-any.whl.
File metadata
- Download URL: pyxvector-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d675ff95319a0d8dac8b5d4d0ca5fedfd2de223c2d29f5865bc37e4efb6837b
|
|
| MD5 |
6a5485bb0200c9ddcd794569675d8159
|
|
| BLAKE2b-256 |
85599ec7ec53b42a8abfa68f929b96118088c0305f0b09d60099d61da0af3ac8
|