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

search

Last update:
May 18, 2026

Description

Performs a similarity search (for example, Nearest Neighbor search) on the vector store. You can search using raw text (if an embedding model is configured) or a vector array. Results can be refined using metadata filters and score thresholds.

Syntax

vectorStoreClient.search(query)

Returns

An array of structs, where each struct contains the item's id, text, vector, metadata, and a similarity score.

Parameters

Parameter
Type
Required
Description
query
Struct
Yes
The search query configuration.
Query struct details
Key
Type
Description
text
String
The text to search for. (Required if vector is not provided).
vector
Array
The query embedding vector. (Required if embeddingModel is not configured).
topK
Numeric
The number of approximate nearest neighbors to return (Overrides client default).
minScore
Numeric
The minimum similarity score (0.0 to 1.0) required for a result to be included.
filter
Struct
A metadata filter expression to narrow the search scope.
Filter operators
The filter struct supports the following operators:
  • Comparison: equals, notEquals, isGreaterThan, isGreaterThanOrEqual, isLessThan, isLessThanOrEqual
  • Set: isIn (array), notIn (array)
  • Logical: and, or, not

Example

<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>

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