Whatever message this page gives is out now! Go check it out!
Goal | Why vectors help |
Answer questions from your own content (RAG) | Retrieve passages that are semantically related to the user’s question, then send them to a chat or completion model. |
“Similar items” in a catalog or knowledge base | Compare the meaning of titles and descriptions, not only keywords. |
Scoped search (tenant, locale, product line) | Combine similarity search with metadata filters so results stay inside the right partition. |
Syncing content from a CMS or ticket system | Upsert by stable ids and delete by filter when content is removed or archived. |
Large documents | Chunk text, embed each chunk, and batch writes to stay within message size and memory limits. |
<cfscript>
try {
vectorstoreclient = VectorStore(); // In-memory; default local embedding model all_minilm (384 dimensions)
docs = [
{
"text": "ColdFusion is a rapid application development platform.",
"metadata": { "category": "tech" }
},
{
"text": "Python is popular for data science.",
"metadata": { "category": "data" }
}
];
addedIds = vectorstoreclient.addAll(docs);
writeDump(addedIds);
}
catch (any e) {
writeOutput("Error initializing VectorStore client:<br><br>");
writeDump(e.detail);
}
</cfscript><cfscript>
try{
vectorstoreclient = VectorStore();
// Single document
oneId = vectorstoreclient.add({
"text": "ColdFusion is a rapid application development platform.",
"metadata": { "category": "tech", "source": "intro" }
});
writeOutput("<h4>add() result (single id)</h4>");
writeDump(oneId);
// Multiple documents
docs = [
{
"text": "Vector databases support similarity search over embeddings.",
"metadata": { "category": "database" }
},
{
// "id": "optional-fixed-id", // optional
"text": "Python is widely used for data science and machine learning.",
"metadata": { "category": "data" }
}
];
addedIds = vectorstoreclient.addAll(docs);
writeOutput("<h4>addAll() result (array of ids)</h4>");
writeDump(addedIds);
}
catch (any e) {
writeOutput("Error initializing VectorStore client:<br><br>");
}
</cfscript><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><cfscript>
try{
vectorstoreclient = VectorStore();
// Single document
oneId = vectorstoreclient.add({
"text": "ColdFusion is a rapid application development platform.",
"metadata": { "category": "tech", "source": "intro" }
});
writeOutput("<h4>add() result (single id)</h4>");
writeDump(oneId);
// Multiple documents
docs = [
{
"text": "Vector databases support similarity search over embeddings.",
"metadata": { "category": "database" }
},
{
// "id": "optional-fixed-id", // optional
"text": "Python is widely used for data science and machine learning.",
"metadata": { "category": "data" }
}
];
addedIds = vectorstoreclient.addAll(docs);
writeOutput("<h4>addAll() result (array of ids)</h4>");
writeDump(addedIds);
}
catch (any e) {
writeOutput("Error initializing VectorStore client:<br><br>");
}
</cfscript><cfscript>
try{
vectorstoreclient = VectorStore({
provider: "inmemory",
embeddingModel: {
"provider": "openai",
"modelName": "text-embedding-3-small",
"apiKey": "#application.apiKey#"
}
});
// Single document
oneId = vectorstoreclient.add({
"text": "ColdFusion is a rapid application development platform.",
"metadata": { "category": "tech", "source": "intro" }
});
writeOutput("<h4>add() result (single id)</h4>");
writeDump(oneId);
// Multiple documents
docs = [
{
"text": "Vector databases support similarity search over embeddings.",
"metadata": { "category": "database" }
},
{
// "id": "optional-fixed-id", // optional
"text": "Python is widely used for data science and machine learning.",
"metadata": { "category": "data" }
}
];
addedIds = vectorstoreclient.addAll(docs);
writeOutput("<h4>addAll() result (array of ids)</h4>");
writeDump(addedIds);
}
catch (any e) {
writeOutput("Error initializing VectorStore client:<br><br>");
}
</cfscript><cfscript>
try {
vectorstoreclient = VectorStore(); // Initializes inmemory vectorstore with all_minilm(local embedding model with 384 dimension)
docs = [
{
"text": "ColdFusion is a rapid application development platform.",
//"embedding": [0.1, 0.2, 0.9], Not required to mention embedding explicitly as we have local embedding model configured by default but if you specify this is prioritized.
"metadata": {"category": "tech"}
},
{
// "id": "2", Id is optional
"text": "Python is popular for Data Science.",
// "embedding": [0.8, 0.1, 0.1],
"metadata": {"category": "data"}
}
];
// Add documents and get their IDs back
addedIds = vectorstoreclient.addAll(docs);
writeDump(addedIds);
} catch (any e) {
writeOutput("Error initializing simple VectorStore client:<br><br> ");
writedump(e.detail);
}
try {
vs = VectorStore({
provider: "inmemory",
embeddingModel: {
"provider": "openai",
"modelName": "text-embedding-3-small",
"apiKey": "#application.apiKey#"
}
/*
For openai embeddingmodel
embeddingModel: {
"provider": "ollama",
"modelName": "qwen3-embedding:8b" // You need to pull the model in ollama, or else you can use openai
}
*/
});
writeDump(vs.add({
"text": "Only text is required"
}));
} catch (any e) {
writeOutput("<hr>Error initializing alternate VectorStore client:<br><br> ");
writedump(e.detail);
}
</cfscript>milvusClient = VectorStore({
provider: "milvus",
url: "https://your-host.example.com:19530",
apiKey: "your-api-key"
}); <cfscript>
vectorStoreAPI = createObject("component", "CFIDE.adminapi.vectorstore");
vectorStoreAPI.addVectorStoreConfig("myMilvus", configStruct);
retrieved = vectorStoreAPI.getVectorStoreConfig("myMilvus");
</cfscript><cfscript>
try {
// Production: use GetVectorStoreClient with provider milvus, pinecone, qdrant, or chroma plus url, apiKey, collectionName, dimension, and embeddingModel.
vectorstoreclient = VectorStore({
"provider": "milvus",
"url" = "milvus_endpoint_url",
"databaseName": "default",
"collectionName": "support_kb",
"dimension": 384,
"indexType": "HNSW",
"metricType": "COSINE",
"embeddingModel": {
"provider": "ollama",
"modelName": "all-minilm:latest",
"baseUrl": "your_endpoint_url",
"maxRetries": 3
}
});
faqChunks = [
{
"id": "faq-reset-1",
"text": "To reset your password, open the login page and select Forgot password. Enter your email and follow the link within 24 hours.",
"metadata": { "articleId": "KB-1001", "department": "accounts", "source": "faq" }
},
{
"id": "faq-billing-1",
"text": "Invoices are generated on the first of each month. You can download PDF copies from Billing > Invoices.",
"metadata": { "articleId": "KB-2040", "department": "billing", "source": "faq" }
},
{
"id": "faq-api-1",
"text": "API rate limits default to 1000 requests per minute per API key. Contact sales for higher tiers.",
"metadata": { "articleId": "KB-3100", "department": "developer", "source": "article" }
}
];
addedIds = vectorstoreclient.addAll(faqChunks);
writeDump(addedIds);
userQuestion = "I forgot my login password and need a new one";
hits = vectorstoreclient.search({
"text": userQuestion,
"topK": 3,
"minScore": 0.45,
"filter": {
"source": "faq",
"$or": [
{ "department": "accounts" },
{ "department": "developer" }
]
}
});
contextBlock = "";
for (i = 1; i <= arrayLen(hits); i++) {
contextBlock &= hits[i].text & chr(10) & chr(10);
}
// Pass contextBlock to your ColdFusion AI service or HTTP call to the LLM as retrieval context.
writeDump(hits);
} catch (any e) {
writeOutput("Knowledge base vector store error:<br><br>");
writeDump(e.detail);
}
</cfscript><cfscript>
try {
vectorstoreclient = VectorStore(); // Default all_minilm (384); prototype only — not for production
products = [
{
"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 }
},
{
"id": "sku-900",
"text": "Stainless steel water bottle 32oz insulated",
"metadata": { "sku": "sku-900", "category": "accessories", "inStock": false }
}
];
writeDump(vectorstoreclient.addAll(products));
currentSku = "sku-501";
seedText = "Trail runner shoes waterproof breathable";
similar = vectorstoreclient.search({
"text": seedText,
"topK": 5,
"minScore": 0.35,
"filter": {
"category": "footwear",
"inStock": true,
"sku": { "$ne": currentSku }
}
});
writeDump(similar);
} catch (any e) {
writeOutput("Catalog vector store error:<br><br>");
writeDump(e.detail);
}
</cfscript><cfscript>
try{
vectorStoreClient=vectorStore({
provider: "inmemory",
embeddingModel: {
"provider": "openai",
"modelName": "text-embedding-3-small",
"apiKey": "#application.apiKey#"
}
})
articles = [
{
"text": "ColdFusion 2025.0.08 adds vector stores for AI workloads.",
"metadata": { "locale": "en-US", "publishedYear": 2026, "section": "product" }
},
{
"text": "Las tiendas vectoriales permiten búsqueda semántica en español.",
"metadata": { "locale": "es-ES", "publishedYear": 2026, "section": "product" }
},
{
"text": "Legacy announcement from 2020 about earlier CF releases.",
"metadata": { "locale": "en-US", "publishedYear": 2020, "section": "archive" }
}
];
writeDump(vectorstoreclient.addAll(articles));
q = vectorstoreclient.search({
"text": "vector database semantic search",
"topK": 5,
"minScore": 0.4,
"filter": {
"locale": "en-US",
"publishedYear": { "$gte": 2025 },
"section": { "$ne": "archive" }
}
});
writeDump(q);
}
catch (any e) {
writeOutput("News search error:<br><br>");
writeDump(e.detail);
}
</cfscript>