Create Predicate Index
Schema
This request accepts an optional schema field. When it is omitted, the server uses the public schema. Set schema to target a store in another schema.
The CreatePredIndex request creates an index on metadata fields to optimize predicate-based queries.
-
Input: Store name and list of predicate keys to index.
-
Behavior: Creates indices on the specified metadata fields for faster filtering.
-
Response: Confirmation of index creation.
Click to expand source code
TypeScript
import { createDbClient } from "ahnlich-client-node";
import { CreatePredIndex } from "ahnlich-client-node/grpc/db/query_pb";
async function createPredicateIndex() {
const client = createDbClient("127.0.0.1:1369");
await client.createPredIndex(
new CreatePredIndex({
store: "my_store",
schema: "analytics",
predicates: ["label", "category"],
})
);
console.log("Predicate indices created successfully");
}
createPredicateIndex();
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
store | string | Yes | The name of the store |
predicates | string[] | Yes | List of metadata keys to index |
Notes
- Indices significantly speed up predicate-based queries (GetPred, filtered GetSimN)
- Creating indices has a one-time cost but improves query performance
- Indices can also be specified during store creation