Skip to main content

Interface: LoadOptions

Defined in: indexes/search-index.ts:59

Options for loading data into an index.

Properties​

batchSize?​

optional batchSize?: number

Defined in: indexes/search-index.ts:83

Number of objects to write in a single Redis pipeline execution.

Default​

200

idField?​

optional idField?: string

Defined in: indexes/search-index.ts:65

Field name to use as the document ID. If provided, the value of this field will be used as the key. If not provided, keys will be auto-generated.


keys?​

optional keys?: string[]

Defined in: indexes/search-index.ts:71

Explicit keys to use for the documents. Must match the length of the data array.


preprocess?​

optional preprocess?: (doc) => Promise<Record<string, unknown>>

Defined in: indexes/search-index.ts:105

Preprocessing function to transform documents before loading. The function receives a document and returns a Promise of the transformed document.

Parameters​

doc​

Record<string, unknown>

Returns​

Promise<Record<string, unknown>>

Example​

// Simple transformation
await index.load(data, {
preprocess: async (doc) => ({ ...doc, timestamp: Date.now() })
});

// generating embeddings
await index.load(data, {
preprocess: async (doc) => ({
...doc,
embedding: await vectorizer.embed(doc.text)
})
});

ttl?​

optional ttl?: number

Defined in: indexes/search-index.ts:77

Time-to-live in seconds for the documents. If provided, documents will expire after this duration.


validateOnLoad?​

optional validateOnLoad?: boolean

Defined in: indexes/search-index.ts:111

Whether to validate documents against schema before loading.

Default​

false