diff --git a/examples/src/test/kotlin/SearchIndexesTest.kt b/examples/src/test/kotlin/SearchIndexesTest.kt index c7d4fcf3..ea6d09c4 100644 --- a/examples/src/test/kotlin/SearchIndexesTest.kt +++ b/examples/src/test/kotlin/SearchIndexesTest.kt @@ -17,6 +17,7 @@ import kotlin.test.assertFalse // "CONNECTION_URI_PLACEHOLDER": "\"\"" // } // } + @TestInstance(TestInstance.Lifecycle.PER_CLASS) class SearchIndexesTest { @@ -42,11 +43,11 @@ class SearchIndexesTest { @Test fun singleSearchIndexTest() = runBlocking { // :snippet-start: single-search-index-create - val index = Document( + val searchIdx = Document( "mappings", Document("dynamic", true) ) - val resultCreateIndex = moviesCollection.createSearchIndex("myIndex", index) + val resultCreateIndex = moviesCollection.createSearchIndex("myIndex", searchIdx) // :snippet-end: println("Index created: $resultCreateIndex") assertEquals("myIndex", resultCreateIndex) @@ -56,24 +57,33 @@ class SearchIndexesTest { @Test fun multipleSearchIndexTest() = runBlocking { // :snippet-start: multi-search-index-create - val indexOne = SearchIndexModel( - "myIndex1", + val searchIdxMdl = SearchIndexModel( + "searchIdx", Document("analyzer", "lucene.standard").append( "mappings", Document("dynamic", true) - ) + ), + SearchIndexType.search() ) - val indexTwo = SearchIndexModel( - "myIndex2", - Document("analyzer", "lucene.simple").append( - "mappings", Document("dynamic", true) - ) + val vectorSearchIdxMdl = SearchIndexModel( + "vsIdx", + Document( + "fields", + listOf( + Document("type", "vector") + .append("path", "embeddings") + .append("numDimensions", 1536) + .append("similarity", "dotProduct") + ) + ), + SearchIndexType.vectorSearch() ) - val resultCreateIndexes = moviesCollection - .createSearchIndexes(listOf(indexOne, indexTwo)) + val resultCreateIndexes = moviesCollection.createSearchIndexes( + listOf(searchIdxMdl, vectorSearchIdxMdl) + ) // :snippet-end: - assertEquals(listOf("myIndex1", "myIndex2"), resultCreateIndexes.toList()) + assertEquals(listOf("searchIdx", "vsIdx"), resultCreateIndexes.toList()) } @Ignore diff --git a/source/examples/generated/SearchIndexesTest.snippet.multi-search-index-create.kt b/source/examples/generated/SearchIndexesTest.snippet.multi-search-index-create.kt index 238dcc8e..79c3f586 100644 --- a/source/examples/generated/SearchIndexesTest.snippet.multi-search-index-create.kt +++ b/source/examples/generated/SearchIndexesTest.snippet.multi-search-index-create.kt @@ -1,16 +1,25 @@ -val indexOne = SearchIndexModel( - "myIndex1", +val searchIdxMdl = SearchIndexModel( + "searchIdx", Document("analyzer", "lucene.standard").append( "mappings", Document("dynamic", true) - ) + ), + SearchIndexType.search() ) -val indexTwo = SearchIndexModel( - "myIndex2", - Document("analyzer", "lucene.simple").append( - "mappings", Document("dynamic", true) - ) +val vectorSearchIdxMdl = SearchIndexModel( + "vsIdx", + Document( + "fields", + listOf( + Document("type", "vector") + .append("path", "embeddings") + .append("numDimensions", 1536) + .append("similarity", "dotProduct") + ) + ), + SearchIndexType.vectorSearch() ) -val resultCreateIndexes = moviesCollection - .createSearchIndexes(listOf(indexOne, indexTwo)) +val resultCreateIndexes = moviesCollection.createSearchIndexes( + listOf(searchIdxMdl, vectorSearchIdxMdl) +) diff --git a/source/examples/generated/SearchIndexesTest.snippet.single-search-index-create.kt b/source/examples/generated/SearchIndexesTest.snippet.single-search-index-create.kt index 1266fd74..74b5b7bc 100644 --- a/source/examples/generated/SearchIndexesTest.snippet.single-search-index-create.kt +++ b/source/examples/generated/SearchIndexesTest.snippet.single-search-index-create.kt @@ -1,5 +1,5 @@ -val index = Document( +val searchIdx = Document( "mappings", Document("dynamic", true) ) -val resultCreateIndex = moviesCollection.createSearchIndex("myIndex", index) +val resultCreateIndex = moviesCollection.createSearchIndex("myIndex", searchIdx) diff --git a/source/fundamentals/indexes.txt b/source/fundamentals/indexes.txt index 305384c4..179e44a2 100644 --- a/source/fundamentals/indexes.txt +++ b/source/fundamentals/indexes.txt @@ -223,19 +223,23 @@ see :manual:`Multikey Indexes ` in the Server manual. .. _kotlin-search-indexes: -Atlas Search Indexes -~~~~~~~~~~~~~~~~~~~~ +Atlas Search and Vector Search Indexes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can programmatically manage your Atlas Search and Atlas Vector +Search indexes by using the {+driver-short+}. The Atlas Search feature enables you to perform full-text searches on -collections hosted on MongoDB Atlas. The indexes specify how you can -perform full-text searches on specific fields. +collections hosted on MongoDB Atlas. To learn more about MongoDB Atlas +Search, see the :atlas:`Atlas Search Indexes +` documentation. -To learn more about MongoDB Atlas Search, see the -:atlas:`Atlas Search Indexes ` -documentation. +Atlas Vector Search enables you to perform semantic searches on vector +embeddings stored in MongoDB Atlas. To learn more about Atlas Vector Search, see the +:ref:`kotlin-atlas-vector-search` section in the Aggregates Builder guide. -You can call the following methods on a collection to manage your Atlas Search -indexes: +You can call the following methods on a collection to manage your Atlas +Search and Vector Search indexes: - ``createSearchIndex()`` - ``createSearchIndexes()`` @@ -258,14 +262,16 @@ Create a Search Index You can use the `createSearchIndex() <{+api+}/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/create-search-index.html>`__ and `createSearchIndexes() <{+api+}/apidocs/mongodb-driver-kotlin-coroutine/mongodb-driver-kotlin-coroutine/com.mongodb.kotlin.client.coroutine/-mongo-collection/create-search-indexes.html>`__ -methods to create Atlas Search indexes on a collection. +methods to create Atlas Search and Vector Search indexes on a +collection. -The following code example shows how to create a single index: +The following code example shows how to create an Atlas Search index: .. literalinclude:: /examples/generated/SearchIndexesTest.snippet.single-search-index-create.kt :language: kotlin -The following code example shows how to create multiple indexes: +The following code example shows how to create Search and +Vector Search indexes in one call: .. literalinclude:: /examples/generated/SearchIndexesTest.snippet.multi-search-index-create.kt :language: kotlin diff --git a/source/whats-new.txt b/source/whats-new.txt index 523226ad..c0b3c0f9 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -12,6 +12,7 @@ What's New Learn what's new in: +* :ref:`Version 5.2 ` * :ref:`Version 5.1.3 ` * :ref:`Version 5.1.2 ` * :ref:`Version 5.1.1 ` @@ -20,6 +21,19 @@ Learn what's new in: * :ref:`Version 4.11 ` * :ref:`Version 4.10 ` +.. _kotlin-coroutine-version-5.2: + +What's New in 5.2 +----------------- + +New features of the 4.11 driver release include: + +.. sharedinclude:: dbx/jvm/v5.2-wn-items.rst + + .. replacement:: avs-index-link + + :ref:`kotlin-search-indexes` in the Indexes guide + .. _kotlin-coroutine-version-5.1.3: What's New in 5.1.3