Skip to content

Commit 2053903

Browse files
authored
DOCSP-42282: java avs index type support (#567)
* DOCSP-42282: java avs type support * shared include fix? * staging * staging * wip * wip * wip * JS comment
1 parent f4b9ab8 commit 2053903

File tree

5 files changed

+53
-23
lines changed

5 files changed

+53
-23
lines changed

snooty.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ toc_landing_pages = [
1313
"/fundamentals/aggregation",
1414
"/usage-examples",
1515
]
16+
1617
sharedinclude_root = "https://raw.githubusercontent.com/10gen/docs-shared/main/"
1718

1819
[constants]

source/fundamentals/builders/aggregates.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,9 @@ pipeline stage that specifies a **semantic search**. A semantic search is
997997
a type of search which locates information that is similar in meaning.
998998

999999
To use this feature, you must set up a vector search index and index your
1000-
vector embeddings. To learn how set these up in MongoDB Atlas, see
1000+
vector embeddings. To learn about how to programmatically create a
1001+
vector search index, see the :ref:`java-search-indexes` section in the Indexes guide. To
1002+
learn more about vector embeddings, see
10011003
:atlas:`How to Index Vector Embeddings for Vector Search </atlas-search/field-types/knn-vector/>`.
10021004

10031005
The following example shows how to build an aggregation pipeline that uses the

source/fundamentals/indexes.txt

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,26 @@ Multikey indexes behave differently from other indexes in terms of query coverag
204204
sort behavior. To learn more about multikey indexes, including a discussion of their behavior and limitations,
205205
see the :manual:`Multikey Indexes page </core/index-multikey>` in the MongoDB manual.
206206

207+
.. _java-search-indexes:
207208
.. _search-indexes:
208209

209-
Atlas Search Indexes
210-
~~~~~~~~~~~~~~~~~~~~
210+
Atlas Search and Vector Search Indexes
211+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
212+
213+
You can programmatically manage your Atlas Search and Atlas Vector
214+
Search indexes by using the {+driver-short+}.
211215

212216
The Atlas Search feature enables you to perform full-text searches on
213-
collections hosted on MongoDB Atlas. The indexes specify the behavior of
214-
the search and which fields to index.
217+
collections hosted on MongoDB Atlas. To learn more about MongoDB Atlas
218+
Search, see the :atlas:`Atlas Search Indexes
219+
</atlas-search/atlas-search-overview/#fts-indexes>` documentation.
215220

216-
To learn more about MongoDB Atlas Search, see the
217-
:atlas:`Atlas Search Indexes </atlas-search/atlas-search-overview/#fts-indexes>`
218-
documentation.
221+
Atlas Vector Search enables you to perform semantic searches on vector
222+
embeddings stored in MongoDB Atlas. To learn more about Atlas Vector Search, see the
223+
:ref:`java-atlas-vector-search` section in the Aggregates Builder guide.
219224

220-
You can call the following methods on a collection to manage your Atlas Search
221-
indexes:
225+
You can call the following methods on a collection to manage your Atlas
226+
Search and Vector Search indexes:
222227

223228
- ``createSearchIndex()``
224229
- ``createSearchIndexes()``
@@ -242,17 +247,18 @@ Create a Search Index
242247
You can use the `createSearchIndex() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#createSearchIndex(org.bson.conversions.Bson)>`__
243248
and the
244249
`createSearchIndexes() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#createSearchIndexes(java.util.List)>`__
245-
methods to create Atlas Search indexes.
250+
methods to create Atlas Search and Vector Search indexes.
246251

247-
The following code example shows how to create a single index:
252+
The following code example shows how to create an Atlas Search index:
248253

249254
.. literalinclude:: /includes/fundamentals/code-snippets/SearchIndexMethods.java
250255
:language: java
251256
:dedent:
252257
:start-after: start create-search-index
253258
:end-before: end create-search-index
254259

255-
The following code example shows how to create multiple indexes:
260+
The following code example shows how to create Search and
261+
Vector Search indexes in one call:
256262

257263
.. literalinclude:: /includes/fundamentals/code-snippets/SearchIndexMethods.java
258264
:language: java

source/includes/fundamentals/code-snippets/SearchIndexMethods.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,36 @@ public static void main( String[] args ) {
2626
MongoCollection<Document> collection = database.getCollection(COLL_NAME);
2727

2828
// start create-search-index
29-
Document index = new Document("mappings",
29+
Document searchIdx = new Document("mappings",
3030
new Document("dynamic", true));
31-
collection.createSearchIndex("myIndex", index);
31+
collection.createSearchIndex("myIndex", searchIdx);
3232
// end create-search-index
33-
33+
3434
// start create-search-indexes
35-
SearchIndexModel indexOne = new SearchIndexModel("myIndex1",
36-
new Document("analyzer", "lucene.standard").append(
37-
"mappings", new Document("dynamic", true)));
35+
SearchIndexModel searchIdxMdl = new SearchIndexModel(
36+
"searchIdx",
37+
new Document("analyzer", "lucene.standard").append(
38+
"mappings", new Document("dynamic", true)),
39+
SearchIndexType.search()
40+
);
3841

39-
SearchIndexModel indexTwo = new SearchIndexModel("myIndex2",
40-
new Document("analyzer", "lucene.simple").append(
41-
"mappings", new Document("dynamic", true)));
42+
SearchIndexModel vectorSearchIdxMdl = new SearchIndexModel(
43+
"vsIdx",
44+
new Document(
45+
"fields",
46+
Arrays.asList(
47+
new Document("type", "vector")
48+
.append("path", "embeddings")
49+
.append("numDimensions", 1536)
50+
.append("similarity", "dotProduct")
51+
)
52+
),
53+
SearchIndexType.vectorSearch()
54+
);
4255

43-
collection.createSearchIndexes(Arrays.asList(indexOne, indexTwo));
56+
collection.createSearchIndexes(
57+
Arrays.asList(searchIdxMdl, vectorSearchIdxMdl)
58+
);
4459
// end create-search-indexes
4560

4661
// start update-search-index

source/whats-new.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ New features of the 5.2 driver release include:
5959
// Connection URI without delimiting forward-slash
6060
String uri = "mongodb://example.com?w=majority";
6161

62+
.. sharedinclude:: dbx/jvm/v5.2-wn-items.rst
63+
64+
.. replacement:: avs-index-link
65+
66+
:ref:`java-search-indexes` in the Indexes guide
67+
6268
.. _java-version-5.1.3:
6369

6470
What's New in 5.1.3

0 commit comments

Comments
 (0)