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

Refine search and manage stored data

Last update:
May 18, 2026

Introduction

Real applications rarely search the entire index in every query. You usually partition data with metadata (tenant, locale, product line, document type) and delete or refresh subsets as content changes. ColdFusion maps filter structs to each backend so you can keep one mental model across providers.
Topic
You will
Ids and embeddings
Supply stable id values when you need them; pass vector when you embed outside the client or override the model for one row.
Metadata filters
Restrict search (and deleteAll) with MongoDB-style operators and equality on plain fields.
Delete
Remove one id, many ids, or every row that matches a filter.
Saved configuration
Register a struct in the Administrator and open the client with vectorStore("alias").
Naming. ColdFusion function names are case-insensitive. Examples use vectorStore().
Note: In-memory data does not survive an application restart. For production, use a hosted provider and the patterns below with your real url, dimension, and credentials.

Pre-requisite

  • ColdFusion 2025.0.08
  • Familiarity with add, addAll, and search using text and optional metadata

Optional ids and stable keys

id is optional. If you omit it, the server can generate an identifier for you. Use an explicit id when you need a stable key that matches another system (CMS record id, ticket number, SKU) so you can delete the same row later without guessing server-generated ids.
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
    vs.add({
        "id": "kb-article-10042",
        "text": "Return policy: items within 30 days with receipt.",
        "metadata": { "docType": "policy", "locale": "en-US" }
    });

    doc=vs.add({
        "text": "Shipping is free over $50.",
        "metadata": { "docType": "marketing", "locale": "en-US" }
    });

    writeDump(doc)
    
    }
    
    catch (any e) {
        writeOutput("Error initializing VectorStore client:<br><br> ");
        writedump(e.detail);
    }
</cfscript>

Metadata filters on search

Filter narrows which rows participate in similarity search. Plain fields mean equals. Operators such as $in, $gte, $ne, and $or follow MongoDB-style syntax and are translated for your provider.
Supported operators (typical set): $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin, $and, $or, $not.
Pass filter as a struct inside search({ ... }).
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
        vs.addAll([
            {
                "text": "ColdFusion is a rapid application development platform.",
                "metadata": { "category": "tech", "audience": "developer", "year": 2023 }
            },
            {
                "text": "Python is popular for data science.",
                "metadata": { "category": "data", "audience": "analyst", "year": 2025 }
            }
        ])
        hits = vs.search({
            "text": "How do I build web apps?",
            "topK": 5,
            "minScore": 0.25,
            "filter": {
                "category": "tech",
                "year": { "$gte": 2023 }
            }
    });

        writeDump(hits);
    } 
    catch (any e) {
        writeOutput("Search error:<br><br>");
        writeDump(e.detail);
    }
</cfscript>

delete and deleteAll

delete(id) removes a single row by id. deleteAll supports:
  • An array of id strings: remove those rows
  • A filter struct: same rules as search; removes every row that matches
  • No arguments: removes all rows in the store (use with care)
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
        id1 = vs.add({
        "text": "Temporary row",
        "metadata": { "batch": "test-2026-03", "status": "draft" }
    });

    vs.delete(id1);

    vs.addAll([
        {
            "text": "Keep me",
            "metadata": { "env": "prod", "retain": true }
        },
        {
            "text": "Remove me",
            "metadata": { "env": "prod", "retain": false }
        }
    ]);

    vs.deleteAll({ "retain": false, "env": "prod" });

    // vs.deleteAll(); // removes everything in this store — uncomment only when intended
    }
    catch(any e){
        writeOutput("Error initializing VectorStore client:<br><br> ");
        writedump(e.detail);
    }
</cfscript>

Register configuration and reuse an alias

Instead of repeating a large struct in every template, register a named configuration in ColdFusion Administrator (or via the Vector Store Admin API after administrator login). Then call vectorStore("yourAlias") to obtain a client.
Example Admin API usage (adjust configStruct to your Milvus, Pinecone, Qdrant, or Chroma settings):
<cfscript>
    try {
        vectorStoreAPI = createObject("component", "CFIDE.adminapi.vectorstore");

        configStruct = {
            "provider": "milvus",
            "url": "http://your-milvus-host:19530",
            "dimension": 384,
            "collectionName": "app_vectors"
            // add apiKey, embeddingModel, connectionSettings, etc. per your deployment
        };

        vectorStoreAPI.addVectorStoreConfig("myMilvus", configStruct);
        retrieved = vectorStoreAPI.getVectorStoreConfig("myMilvus");
        writeDump(retrieved);

        vectorstoreclient = vectorStore("myMilvus");
        writeDump(vectorstoreclient.add({
            "text": "Document added through aliased client.",
            "metadata": { "via": "alias" }
        }));
    } 
    catch (any e) {
        writeDump(e);
    }
</cfscript>
Use modifyVectorStoreConfig, deleteVectorStoreConfig, and getAllVectorStoreConfigs when you maintain the lifecycle of these entries.

Use cases

Use case 1: Support articles filtered by department
Scenario: You indexed FAQ snippets with department in metadata. Support agents search only account and billing content.
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
        vs.addAll([
            {
                "text": "Reset your password from the login screen.",
                "metadata": { "department": "accounts", "source": "faq" }
            },
            {
                "text": "Download invoices under Billing.",
                "metadata": { "department": "billing", "source": "faq" }
            },
            {
                "text": "API keys are listed under Developer settings.",
                "metadata": { "department": "developer", "source": "faq" }
            }
        ]);

        hits = vs.search({
            "text": "Where is my invoice?",
            "topK": 5,
            "minScore": 0.3,
            "filter": {
                "source": "faq",
                "$or": [
                    { "department": "accounts" },
                    { "department": "billing" }
                ]
            }
        });

        writeDump(hits);
        }
        catch(any e){
            writeOutput("Error initializing VectorStore client:<br><br> ");
            writedump(e.detail);
        }
</cfscript>
Use case 2: Similar items in one category, excluding the current SKU
Scenario: A product detail page shows similar products in the same category, but not the product the shopper is already viewing.
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
        vs.addAll([
            {
                "id": "sku-501",
                "text": "Trail runner shoes waterproof breathable size 7–12 black",
                "metadata": { "sku": "sku-501", "category": "footwear", "inStock": true }
            },
            {
                "id": "sku-502",
                "text": "Lightweight hiking boots leather ankle support waterproof",
                "metadata": { "sku": "sku-502", "category": "footwear", "inStock": true }
            }
        ]);

        currentSku = "sku-501";

        similar = vs.search({
            "text": "Trail runner shoes waterproof breathable",
            "topK": 5,
            "minScore": 0.35,
            "filter": {
                "category": "footwear",
                "inStock": true,
                "sku": { "$ne": currentSku }
            }
        });

        writeDump(similar);
    } catch(any e){
        writeOutput("Error initializing VectorStore client:<br><br> ");
        writedump(e.detail);
    }
</cfscript>
Use case 3: Remove archived content by filter
Scenario: A job marks status = archived in your source system. You remove matching vectors from the index with deleteAll and a filter, without listing ids.
<cfscript>
    try{
        vs = VectorStore({
            provider: "inmemory",
            embeddingModel: {
                "provider": "openai",
                "modelName": "text-embedding-3-small",
                "apiKey": "#application.apiKey#"
            }
        });
        vs.addAll([
        {
            "text": "Active announcement.",
            "metadata": { "articleId": "a1", "status": "published" }
        },
        {
            "text": "Old announcement.",
            "metadata": { "articleId": "a2", "status": "archived" }
        }
    ]);

        vs.deleteAll({ "status": "archived" });

        remaining = vs.search({
            "text": "announcement",
            "topK": 5,
            "minScore": 0.2
        });

        writeDump(remaining);
    } catch(any e){
        writeOutput("Error initializing VectorStore client:<br><br> ");
        writedump(e.detail);
    }
</cfscript>

Error handling

Invalid filter syntax or unsupported fields can cause VectorStoreInvalidFilterException (or the exception name your release maps to). Wrap production code in cftry / cfcatch and log cfcatch.detail for troubleshooting.

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