From a2fdd026da0dead0a27c7b076c69ac9bce3d7972 Mon Sep 17 00:00:00 2001 From: Rea Rustagi <85902999+rustagir@users.noreply.github.com> Date: Thu, 14 Mar 2024 14:59:03 -0400 Subject: [PATCH] DOCSP-37442: show vector search idx creation (#883) * DOCSP-37442: show vs index creation * update * staging * fixes * MW PR fixes 1 (cherry picked from commit 4cf3cdae1aa5c6d8e06e2cc1c2b6ff197c4a43c8) --- source/code-snippets/indexes/searchIndexes.js | 18 ++++++++++++++++++ source/fundamentals/indexes.txt | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/source/code-snippets/indexes/searchIndexes.js b/source/code-snippets/indexes/searchIndexes.js index e4fc0df77..97639bbbe 100644 --- a/source/code-snippets/indexes/searchIndexes.js +++ b/source/code-snippets/indexes/searchIndexes.js @@ -28,6 +28,24 @@ async function run() { await collection.createSearchIndex(index1); // end createSearchIndex example + // start vectorSearchIdx example + // Create a Vector Search index + const vectorSearchIdx = { + name: "vsidx1", + type: "vectorSearch", + definition: { + fields: [{ + type: "vector", + numDimensions: 384, + path: "summary", + similarity: "dotProduct" + }] + } + } + + await collection.createSearchIndex(vectorSearchIdx); + // end vectorSearchIdx example + // start listSearchIndexes example const result = await collection.listSearchIndexes().toArray(); console.log("Existing search indexes:\n"); diff --git a/source/fundamentals/indexes.txt b/source/fundamentals/indexes.txt index 260a26ac8..4ab5db00c 100644 --- a/source/fundamentals/indexes.txt +++ b/source/fundamentals/indexes.txt @@ -374,6 +374,22 @@ use the ``createSearchIndex()`` method to create an index called :start-after: start createSearchIndex example :end-before: end createSearchIndex example +When connecting to {+mdb-server+} v6.0.11 and later v6 versions, or +v7.0.2 and later v7 versions, you can use the driver to create an Atlas +Vector Search index on a collection. Learn more about this feature in +the :atlas:`Atlas Vector Search documentation +`. + +The following code shows how to use the ``createSearchIndex()`` method +to create a search index in which the ``type`` field is +``vectorSearch``: + +.. literalinclude:: /code-snippets/indexes/searchIndexes.js + :language: javascript + :dedent: + :start-after: start vectorSearchIdx example + :end-before: end vectorSearchIdx example + List Search Indexes ~~~~~~~~~~~~~~~~~~~