Indexes
A vector index is declared once in application code. The index configuration is immutable after creation — changing dimensions or metric requires a new index and re-ingestion.
Required Options
Section titled “Required Options”Stable name for the index inside the Layeron app. Layeron uses the name for binding derivation and Cloudflare resource naming.
vector({ name: "docs", dimensions: 768 })dimensions
Section titled “dimensions”Number of dimensions in each vector. Must match the output of the embedding model.
- Type: integer
- Range:
1—1536
vector({ name: "docs", dimensions: 768 })Optional Configuration
Section titled “Optional Configuration”metric
Section titled “metric”Similarity metric for distance calculations.
| Value | Description |
|---|---|
"cosine" (default) | Cosine similarity |
"euclidean" | Euclidean distance |
"dot_product" | Dot product similarity |
vector({ name: "docs", dimensions: 768, metric: "euclidean" })namespace
Section titled “namespace”Platform namespace for the index. Defaults to "default".
Namespaces keep multiple indexes with the same name isolated from each other. They are part of the stable platform identity and affect binding and Cloudflare resource naming.
vector({ name: "docs", namespace: "search", dimensions: 768 })binding
Section titled “binding”Worker binding name for the Cloudflare Vectorize binding. Omit to let Layeron derive a stable binding name automatically.
vector({ name: "docs", binding: "MY_BINDING", dimensions: 768 })metadata.indexes
Section titled “metadata.indexes”Metadata fields indexed for query filtering. Indexed fields let you filter query results by metadata value.
Each entry requires a propertyName and a type:
| Type | Description |
|---|---|
"string" | String metadata field |
| `“number” | Number metadata field |
"boolean" | Boolean metadata field |
vector({ name: "docs", dimensions: 768, metadata: { indexes: [ { propertyName: "tenantId", type: "string" }, { propertyName: "sourceId", type: "string" }, ], },})Full Example
Section titled “Full Example”const docs = vector({ name: "docs", namespace: "search", dimensions: 768, metric: "cosine", metadata: { indexes: [ { propertyName: "tenantId", type: "string" }, ], },})