Skip to main content

Create Store

The CreateStore request creates a new vector store on the Ahnlich DB server.

  • Input: Store name, dimension, optional predicates, and error handling flag.

  • Behavior: Creates a new store with the specified configuration. The dimension is fixed at creation - all inserted vectors must match it.

  • Response: Confirmation of store creation.

Click to expand source code
import { createDbClient } from "ahnlich-client-node";
import { CreateStore } from "ahnlich-client-node/grpc/db/query_pb";

async function createStore() {
const client = createDbClient("127.0.0.1:1369");

await client.createStore(
new CreateStore({
store: "my_store",
dimension: 4,
predicates: ["label", "category"],
errorIfExists: true,
})
);

console.log("Store created successfully");
}

createStore();

Parameters​

ParameterTypeRequiredDescription
storestringYesThe name for the new store
dimensionnumberYesVector dimension (all vectors must match this)
predicatesstring[]NoList of predicate keys to index
errorIfExistsbooleanNoIf true, throws error if store exists; if false, silently ignores

Example with All Options​

Click to expand source code
import { createDbClient } from "ahnlich-client-node";
import { CreateStore } from "ahnlich-client-node/grpc/db/query_pb";

async function createStoreWithOptions() {
const client = createDbClient("127.0.0.1:1369");

// Create a store for 128-dimensional embeddings
// with predicate indices on "title" and "author"
await client.createStore(
new CreateStore({
store: "book_embeddings",
dimension: 128,
predicates: ["title", "author", "genre"],
errorIfExists: false, // Don't error if already exists
})
);
}

createStoreWithOptions();

Notes​