Create Non-Linear Algorithm Index
Creates a non-linear algorithm index on a vector store within the AI service to optimize similarity search performance. These indexes accelerate nearest-neighbor and semantic searches over large embedding datasets, making retrieval faster and more efficient.
Source Code Exampleβ
Click to expand
use ahnlich_client_rs::ai::AiClient;
use ahnlich_types::ai::query::CreateNonLinearAlgorithmIndex;
use ahnlich_types::algorithm::nonlinear::NonLinearAlgorithm;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = AiClient::new("http://127.0.0.1:1370".to_string()).await?;
let params = CreateNonLinearAlgorithmIndex {
store: "MyStore".to_string(),
non_linear_indices: vec![NonLinearAlgorithm::KdTree as i32],
};
let result = client.create_non_linear_algorithm_index(params, None).await?;
println!("Created non-linear indices: {:?}", result);
Ok(())
}
Parametersβ
params: CreateNonLinearAlgorithmIndexβ Specifies the target store and algorithm parameters for building the non-linear index.
Returnsβ
-
Ok(CreateIndex)β Confirmation that the non-linear algorithm index was successfully created, including index details. -
Err(AhnlichError)β Returned if index creation fails due to invalid parameters, store issues, or server errors.
Behavior (explains the code, brief)β
-
Wraps the
CreateNonLinearAlgorithmIndexinput in atonic::Request. -
Attaches tracing metadata if provided.
-
Calls the AI serviceβs
create_non_linear_algorithm_indexRPC endpoint. -
Awaits the response and extracts the result.
-
Returns a
CreateIndexobject with details of the created index.