Skip to main content

Create a store

Create a new, isolated store — Ahnlich's container for vectors and their metadata, like a collection in a document database or a table in a relational one.

Every operation works on both Vector DB stores (you supply raw vectors) and AI stores (you supply text or images and Ahnlich AI generates the embeddings for you). Use the Vector DB / AI switch in the sample below.

Parameters

ParameterTypeDescription
storestringUnique name for the store.
dimensionintVector dimensionality — every key must match this length.
create_predicateslist · optionalMetadata fields to index for filtering (seeds a predicate index).
non_linear_indiceslist · optionalNon-linear algorithms for approximate search (see non-linear index).
error_if_existsboolIf true, returns an error when the store already exists.

All requests accept an optional schema field. When omitted, the server uses the public schema.

Behavior

  • Creates a new isolated store; many stores can coexist for different workloads.
  • The dimension is fixed at creation — every vector key must match it.
  • You can seed predicate and non-linear indexes here, or add them later.

Sample query

Python
import asyncio
from grpclib.client import Channel
from ahnlich_client_py.grpc.services.db_service import DbServiceStub
from ahnlich_client_py.grpc.db import query as db_query
from ahnlich_client_py.grpc.db.server import Unit

async def create_store():
async with Channel(host="127.0.0.1", port=1369) as channel:
client = DbServiceStub(channel)
response = await client.create_store(
db_query.CreateStore(
store="my_store",
schema="analytics",
dimension=4, # Fixed vector dimension
create_predicates=["label", "category"], # Index these metadata fields
non_linear_indices=[], # Optional: non-linear algorithms for faster search
error_if_exists=True
)
)
# response is Unit() on success

# All store_keys must match this dimension
# Example valid key:
valid_key = [1.0, 2.0, 3.0, 4.0, 5.0] # length = 5
assert isinstance(response, Unit)
if __name__ == "__main__":
asyncio.run(create_store())

Response

A confirmation message (Unit).