Skip to content

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.

Stable name for the index inside the Layeron app. Layeron uses the name for binding derivation and Cloudflare resource naming.

Terminal window
vector({ name: "docs", dimensions: 768 })

Number of dimensions in each vector. Must match the output of the embedding model.

  • Type: integer
  • Range: 11536
Terminal window
vector({ name: "docs", dimensions: 768 })

Similarity metric for distance calculations.

ValueDescription
"cosine" (default)Cosine similarity
"euclidean"Euclidean distance
"dot_product"Dot product similarity
Terminal window
vector({ name: "docs", dimensions: 768, metric: "euclidean" })

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.

Terminal window
vector({ name: "docs", namespace: "search", dimensions: 768 })

Worker binding name for the Cloudflare Vectorize binding. Omit to let Layeron derive a stable binding name automatically.

Terminal window
vector({ name: "docs", binding: "MY_BINDING", dimensions: 768 })

Metadata fields indexed for query filtering. Indexed fields let you filter query results by metadata value.

Each entry requires a propertyName and a type:

TypeDescription
"string"String metadata field
`“number”Number metadata field
"boolean"Boolean metadata field
Terminal window
vector({
name: "docs",
dimensions: 768,
metadata: {
indexes: [
{ propertyName: "tenantId", type: "string" },
{ propertyName: "sourceId", type: "string" },
],
},
})
Terminal window
const docs = vector({
name: "docs",
namespace: "search",
dimensions: 768,
metric: "cosine",
metadata: {
indexes: [
{ propertyName: "tenantId", type: "string" },
],
},
})