Whatever message this page gives is out now! Go check it out!

add

Last update:
May 18, 2026

Description

Adds a single item (document) to the vector store. If an embedding model is configured in the client, the vector parameter is optional, and the text will be automatically embedded.

Syntax

vectorStoreClient.add(item)

Parameters

Parameter
Type
Required
Description
item
Struct
Yes
The data structure representing the item to store.
Item struct details
Key
Type
Required
Description
id
String
No
Unique identifier. If omitted, one may be auto-generated by the provider or CF.
text
String
Yes
The raw text content of the document.
vector
Array
No
Array of floats representing the embedding. Required only if no embeddingModel is configured on the client.
metadata
Struct
No
Key-value pairs for filtering (e.g., category, date).

Returns

A string containing the ID of the added item.

Example

<cfscript>
    try {
        vectorstoreclient = vectorStore({
            "provider": "milvus",
            "url": "http://your-milvus-host:19530",
            "databaseName": "default",
            "collectionName": "cf_docs",
            "dimension": 768,
            "metricType": "COSINE",
            "indexType": "HNSW",
            "apiKey": "",
            "embeddingModel": {
                "provider": "ollama",
                "modelName": "nomic-embed-text:latest",
                "baseUrl": "http://localhost:11434",
                "dimension": 768
            }
        });

        writeDump(vectorstoreclient.add({
            "text": "ColdFusion is a rapid application development platform.",
            "metadata": { "product": "coldfusion", "year": 2025 }
        }));

        writeDump(vectorstoreclient.search({
            "text": "rapid application development",
            "minScore": 0.25,
            "topK": 5,
            "filter": { "year": 2025 }
        }));
    } 
    catch (any e) {
        writeDump(e);
    }
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page