diff --git a/snooty.toml b/snooty.toml index 6b9d3c3b0..5aad49261 100644 --- a/snooty.toml +++ b/snooty.toml @@ -13,6 +13,7 @@ toc_landing_pages = [ "/fundamentals/aggregation", "/usage-examples", ] + sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/" [constants] diff --git a/source/fundamentals/builders/aggregates.txt b/source/fundamentals/builders/aggregates.txt index 4b9b2b58f..9c150bb50 100644 --- a/source/fundamentals/builders/aggregates.txt +++ b/source/fundamentals/builders/aggregates.txt @@ -997,7 +997,9 @@ pipeline stage that specifies a **semantic search**. A semantic search is a type of search which locates information that is similar in meaning. To use this feature, you must set up a vector search index and index your -vector embeddings. To learn how set these up in MongoDB Atlas, see +vector embeddings. To learn about how to programmatically create a +vector search index, see the :ref:`java-search-indexes` section in the Indexes guide. To +learn more about vector embeddings, see :atlas:`How to Index Vector Embeddings for Vector Search `. The following example shows how to build an aggregation pipeline that uses the diff --git a/source/fundamentals/indexes.txt b/source/fundamentals/indexes.txt index f05be7497..2e3f27f38 100644 --- a/source/fundamentals/indexes.txt +++ b/source/fundamentals/indexes.txt @@ -204,21 +204,26 @@ Multikey indexes behave differently from other indexes in terms of query coverag sort behavior. To learn more about multikey indexes, including a discussion of their behavior and limitations, see the :manual:`Multikey Indexes page ` in the MongoDB manual. +.. _java-search-indexes: .. _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 the behavior of -the search and which fields to index. +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:`java-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()`` @@ -242,9 +247,9 @@ Create a Search Index You can use the `createSearchIndex() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#createSearchIndex(org.bson.conversions.Bson)>`__ and the `createSearchIndexes() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#createSearchIndexes(java.util.List)>`__ -methods to create Atlas Search indexes. +methods to create Atlas Search and Vector Search indexes. -The following code example shows how to create a single index: +The following code example shows how to create an Atlas Search index: .. literalinclude:: /includes/fundamentals/code-snippets/SearchIndexMethods.java :language: java @@ -252,7 +257,8 @@ The following code example shows how to create a single index: :start-after: start create-search-index :end-before: end create-search-index -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:: /includes/fundamentals/code-snippets/SearchIndexMethods.java :language: java diff --git a/source/includes/fundamentals/code-snippets/SearchIndexMethods.java b/source/includes/fundamentals/code-snippets/SearchIndexMethods.java index ba9a40031..b3ea68f99 100644 --- a/source/includes/fundamentals/code-snippets/SearchIndexMethods.java +++ b/source/includes/fundamentals/code-snippets/SearchIndexMethods.java @@ -26,21 +26,36 @@ public static void main( String[] args ) { MongoCollection collection = database.getCollection(COLL_NAME); // start create-search-index - Document index = new Document("mappings", + Document searchIdx = new Document("mappings", new Document("dynamic", true)); - collection.createSearchIndex("myIndex", index); + collection.createSearchIndex("myIndex", searchIdx); // end create-search-index - + // start create-search-indexes - SearchIndexModel indexOne = new SearchIndexModel("myIndex1", - new Document("analyzer", "lucene.standard").append( - "mappings", new Document("dynamic", true))); + SearchIndexModel searchIdxMdl = new SearchIndexModel( + "searchIdx", + new Document("analyzer", "lucene.standard").append( + "mappings", new Document("dynamic", true)), + SearchIndexType.search() + ); - SearchIndexModel indexTwo = new SearchIndexModel("myIndex2", - new Document("analyzer", "lucene.simple").append( - "mappings", new Document("dynamic", true))); + SearchIndexModel vectorSearchIdxMdl = new SearchIndexModel( + "vsIdx", + new Document( + "fields", + Arrays.asList( + new Document("type", "vector") + .append("path", "embeddings") + .append("numDimensions", 1536) + .append("similarity", "dotProduct") + ) + ), + SearchIndexType.vectorSearch() + ); - collection.createSearchIndexes(Arrays.asList(indexOne, indexTwo)); + collection.createSearchIndexes( + Arrays.asList(searchIdxMdl, vectorSearchIdxMdl) + ); // end create-search-indexes // start update-search-index diff --git a/source/whats-new.txt b/source/whats-new.txt index ce0c232d5..17c9467ed 100644 --- a/source/whats-new.txt +++ b/source/whats-new.txt @@ -59,6 +59,12 @@ New features of the 5.2 driver release include: // Connection URI without delimiting forward-slash String uri = "mongodb://example.com?w=majority"; +.. sharedinclude:: dbx/jvm/v5.2-wn-items.rst + + .. replacement:: avs-index-link + + :ref:`java-search-indexes` in the Indexes guide + .. _java-version-5.1.3: What's New in 5.1.3