Skip to content

CreateIndex

Source: src/AWS/OpenSearchServerless/CreateIndex.ts

Runtime binding for the CreateIndex operation scoped to one collection (IAM action aoss:APIAccessAll on the collection ARN).

Creates an index in the bound Collection from inside a function runtime — the control-plane path for the multi-tenant pattern where each tenant gets its own (vector) index. The calling principal must also be granted aoss:CreateIndex on the index pattern by a data AccessPolicy. Provide the implementation with Effect.provide(AWS.OpenSearchServerless.CreateIndexHttp).

// init — bind the operation to the collection
const createIndex = yield* AWS.OpenSearchServerless.CreateIndex(collection);
// runtime
yield* createIndex({
indexName: `tenant-${tenantId}`,
indexSchema: {
mappings: {
properties: {
embedding: { type: "knn_vector", dimension: 1536 },
},
},
},
});