Drop non-linear index
Remove a non-linear index (HNSW) from a store.
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
| Parameter | Type | Description |
|---|---|---|
store | string | Store to modify. |
non_linear_indices | list | The index types to drop. |
schema | string · optional | Schema to target. Defaults to public. |
All requests accept an optional
schemafield. When omitted, the server uses thepublicschema.
Behavior
- Deletes the index only — stored vectors and metadata are untouched.
- Similarity search still works, falling back to a linear scan.
Sample query
- Database engine
- AI proxy
- Python
- Node.js
- Go
- Rust
- CLI
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.algorithm.nonlinear import NonLinearAlgorithm
async def drop_non_linear_algo():
async with Channel(host="127.0.0.1", port=1369) as channel:
client = DbServiceStub(channel)
response = await client.drop_non_linear_algorithm_index(
db_query.DropNonLinearAlgorithmIndex(
store="my_store",
schema="analytics",
non_linear_indices=[NonLinearAlgorithm.HNSW],
error_if_not_exists=True
)
)
# response.deleted_count shows how many indexes were removed
print(response)
if __name__ == "__main__":
asyncio.run(drop_non_linear_algo())
TypeScript
import { createDbClient } from "ahnlich-client-node";
import { DropNonLinearAlgorithmIndex } from "ahnlich-client-node/grpc/db/query_pb";
import { NonLinearAlgorithm } from "ahnlich-client-node/grpc/algorithm/nonlinear_pb";
async function dropNonLinearIndex() {
const client = createDbClient("127.0.0.1:1369");
await client.dropNonLinearAlgorithmIndex(
new DropNonLinearAlgorithmIndex({
store: "my_store",
schema: "analytics",
nonLinearIndices: [NonLinearAlgorithm.HNSW],
errorIfNotExists: true,
})
);
console.log("HNSW index dropped successfully");
}
dropNonLinearIndex();
Go
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
dbsvc "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/services/db_service"
dbquery "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/db/query"
nonlinear "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/algorithm/nonlinear"
)
const ServerAddr = "127.0.0.1:1369"
func stringPtr(value string) *string { return &value }
type ExampleDBClient struct {
conn *grpc.ClientConn
client dbsvc.DBServiceClient
ctx context.Context
}
func NewDBClient(ctx context.Context) (*ExampleDBClient, error) {
conn, err := grpc.NewClient(ServerAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("failed to dial DB server %q: %w", ServerAddr, err)
}
client := dbsvc.NewDBServiceClient(conn)
return &ExampleDBClient{conn: conn, client: client, ctx: ctx}, nil
}
func (c *ExampleDBClient) Close() error {
return c.conn.Close()
}
func (c *ExampleDBClient) exampleDropNonLinearAlgoIndex() error {
_, err := c.client.DropNonLinearAlgorithmIndex(c.ctx, &dbquery.DropNonLinearAlgorithmIndex{
Store: "my_store",
Schema: stringPtr("analytics"), // Optional: defaults to public when omitted
NonLinearIndices: []nonlinear.NonLinearAlgorithm{nonlinear.NonLinearAlgorithm_HNSW},
ErrorIfNotExists: true,
})
return err
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
client, err := NewDBClient(ctx)
if err != nil {
log.Fatalf("Failed to create DB client: %v", err)
}
defer client.Close()
if err := client.exampleDropNonLinearAlgoIndex(); err != nil {
log.Fatalf("DropNonLinearAlgoIndex failed: %v", err)
}
fmt.Println("Dropped Non-Linear Algorithm Index for 'my_store'")
}
Rust
use ahnlich_types::db::query::DropNonLinearAlgorithmIndex;
use ahnlich_types::algorithm::nonlinear::NonLinearAlgorithm;
use ahnlich_types::db::server::Del;
use ahnlich_client_rs::db::DbClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let addr = "http://127.0.0.1:1369".to_string();
let db_client = DbClient::new(addr).await?;
let params = DropNonLinearAlgorithmIndex {
store: "my_store".to_string(),
schema: Some("analytics".to_string()),
non_linear_indices: vec![NonLinearAlgorithm::Hnsw as i32],
error_if_not_exists: false,
};
match db_client
.drop_non_linear_algorithm_index(params, None)
.await
{
Ok(Del { deleted_count }) => {
println!("Successfully dropped {} non-linear index(es).", deleted_count);
}
Err(e) => {
eprintln!("Error dropping non-linear index: {:?}", e);
}
}
Ok(())
}
DROPNONLINEARALGORITHMINDEX (hnsw) IN my_store- Python
- Node.js
- Go
- Rust
- CLI
Python
import asyncio
from grpclib.client import Channel
from ahnlich_client_py.grpc.services.ai_service import AiServiceStub
from ahnlich_client_py.grpc.ai import query as ai_query
from ahnlich_client_py.grpc.algorithm.nonlinear import NonLinearAlgorithm
async def drop_non_linear_algorithm_index():
async with Channel(host="127.0.0.1", port=1370) as channel:
client = AiServiceStub(channel)
response = await client.drop_non_linear_algorithm_index(
ai_query.DropNonLinearAlgorithmIndex(
store="my_store",
schema="analytics",
non_linear_indices=[NonLinearAlgorithm.HNSW],
error_if_not_exists=True
)
)
print(response) # Del(deleted_count=1)
if __name__ == "__main__":
asyncio.run(drop_non_linear_algorithm_index())
TypeScript
import { createAiClient } from "ahnlich-client-node";
import { DropNonLinearAlgorithmIndex } from "ahnlich-client-node/grpc/ai/query_pb";
import { NonLinearAlgorithm } from "ahnlich-client-node/grpc/algorithm/nonlinear_pb";
async function dropNonLinearIndex() {
const client = createAiClient("127.0.0.1:1370");
await client.dropNonLinearAlgorithmIndex(
new DropNonLinearAlgorithmIndex({
store: "ai_store",
schema: "analytics",
nonLinearIndices: [NonLinearAlgorithm.HNSW],
errorIfNotExists: true,
})
);
console.log("HNSW index dropped");
}
dropNonLinearIndex();
Go
package main
import (
"context"
"fmt"
"log"
"time"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
aiquery "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/ai/query"
aisvc "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/services/ai_service"
nonlinear "github.com/deven96/ahnlich/sdk/ahnlich-client-go/grpc/algorithm/nonlinear"
)
const AIAddr = "127.0.0.1:1370"
// ExampleAIClient wraps the connection + AIService client
func stringPtr(value string) *string { return &value }
type ExampleAIClient struct {
conn *grpc.ClientConn
client aisvc.AIServiceClient
ctx context.Context
}
// NewAIClient connects to the AI server
func NewAIClient(ctx context.Context) (*ExampleAIClient, error) {
conn, err := grpc.DialContext(ctx, AIAddr,
grpc.WithTransportCredentials(insecure.NewCredentials()),
grpc.WithBlock(),
)
if err != nil {
return nil, fmt.Errorf("failed to dial AI server %q: %w", AIAddr, err)
}
client := aisvc.NewAIServiceClient(conn)
return &ExampleAIClient{conn: conn, client: client, ctx: ctx}, nil
}
func (c *ExampleAIClient) Close() error {
return c.conn.Close()
}
// ---- DropNonLinearAlgorithmIndex standalone ----
func (c *ExampleAIClient) exampleDropNonLinearIndexAI() error {
_, err := c.client.DropNonLinearAlgorithmIndex(c.ctx, &aiquery.DropNonLinearAlgorithmIndex{
Store: "ai_store",
Schema: stringPtr("analytics"), // Optional: defaults to public when omitted
NonLinearIndices: []nonlinear.NonLinearAlgorithm{nonlinear.NonLinearAlgorithm_HNSW},
ErrorIfNotExists: true,
})
if err != nil {
return err
}
fmt.Println(" Successfully dropped NonLinearAlgorithm index: HNSW from store ai_store")
return nil
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
client, err := NewAIClient(ctx)
if err != nil {
log.Fatalf(" Failed to create AI client: %v", err)
}
defer client.Close()
if err := client.exampleDropNonLinearIndexAI(); err != nil {
log.Fatalf(" DropNonLinearAlgorithmIndex failed: %v", err)
}
}
Rust
use ahnlich_client_rs::ai::AiClient;
use ahnlich_types::ai::query::DropNonLinearAlgorithmIndex;
use ahnlich_types::algorithm::nonlinear::NonLinearAlgorithm;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to AI server
let client = AiClient::new("http://127.0.0.1:1370".to_string()).await?;
// Set parameters for dropping the non-linear index
let params = DropNonLinearAlgorithmIndex {
store: "MyStore".to_string(),
schema: Some("analytics".to_string()),
non_linear_indices: vec![NonLinearAlgorithm::Hnsw as i32],
error_if_not_exists: true, // error if the index doesn't exist
};
// Execute drop request
let result = client
.drop_non_linear_algorithm_index(params, None)
.await?;
println!("Dropped non-linear indices: {:?}", result);
Ok(())
}
DROPNONLINEARALGORITHMINDEX (hnsw) IN my_storeResponse
The number of indexes deleted.