Create Store
Creates a new vector store within the Ahnlich DB service. A store is the primary container for vectors and metadata, and all vector operations must be scoped to a specific store. This request is essential for initializing logical partitions of data before inserting or querying vectors.
Source Code Exampleβ
Click to expand
use ahnlich_client_rs::db::DbClient;
use ahnlich_types::db::query::CreateStore;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to server
let db_client = DbClient::new("127.0.0.1:1369".to_string()).await?;
let tracing_id: Option<String> = None;
// Define parameters for store creation
let params = CreateStore {
store: "Main".to_string(),
dimension: 3,
create_predicates: vec!["role".to_string()],
non_linear_indices: vec![],
error_if_exists: true,
};
// Call create_store
match db_client.create_store(params, tracing_id).await {
Ok(res) => {
println!("Store created successfully: {:?}", res);
}
Err(err) => {
eprintln!("Error creating store: {:?}", err);
}
}
Ok(())
}
Parametersβ
params: CreateStoreβ The configuration for the new store. This includes required fields such as the store name, vector dimensionality, and optional indexing options..
Returnsβ
-
Ok(Unit)β Indicates that the store was successfully created. -
Err(AhnlichError)β Returned if the request fails. Common failure cases include:-
A store with the same name already exists.
-
Invalid configuration parameters (e.g., mismatched dimensions).
-
Server-side or transport-level errors.
-
Behaviorβ
-
This is a write operation and will allocate resources on the server.
-
Once created, the store immediately becomes available for other operations such as
Set,Get Sim N, or predicate-based queries. -
Tracing information, if provided, is propagated through the request for monitoring and debugging.
Usage considerationsβ
-
Use
List Storesafter creation to verify that the store has been registered successfully. -
Stores are persistent until explicitly removed using
Drop Store. -
Proper planning of store dimensions and indexing strategy is recommended, as these cannot be trivially changed after creation.