Skip to content

DOCSP-42282: java avs index type support #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions snooty.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ toc_landing_pages = [
"/fundamentals/aggregation",
"/usage-examples",
]

sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"

[constants]
Expand Down
4 changes: 3 additions & 1 deletion source/fundamentals/builders/aggregates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 </atlas-search/field-types/knn-vector/>`.

The following example shows how to build an aggregation pipeline that uses the
Expand Down
30 changes: 18 additions & 12 deletions source/fundamentals/indexes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 </core/index-multikey>` 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
</atlas-search/atlas-search-overview/#fts-indexes>` documentation.

To learn more about MongoDB Atlas Search, see the
:atlas:`Atlas Search Indexes </atlas-search/atlas-search-overview/#fts-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()``
Expand All @@ -242,17 +247,18 @@ 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
:dedent:
: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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,36 @@ public static void main( String[] args ) {
MongoCollection<Document> 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
Expand Down
6 changes: 6 additions & 0 deletions source/whats-new.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading