@@ -9,7 +9,7 @@ Atlas Vector Search
9
9
:values: reference
10
10
11
11
.. meta::
12
- :keywords: full text, text analyzer, meta, pipeline, scoring, Lucene, AI, artificial intelligence
12
+ :keywords: full text, text analyzer, meta, pipeline, scoring, Lucene, AI, artificial intelligence, code example, semantic, nearest
13
13
:description: Learn about how to use Atlas Vector Search in the {+driver-long+}.
14
14
15
15
.. contents:: On this page
@@ -18,5 +18,90 @@ Atlas Vector Search
18
18
:depth: 2
19
19
:class: singlecol
20
20
21
- See :atlas:`Atlas Vector Search </atlas-vector-search/vector-search-overview/>`
22
- in the MongoDB Atlas documentation.
21
+ Overview
22
+ --------
23
+
24
+ In this guide, you can learn how to use the :atlas:`Atlas Vector Search
25
+ </atlas-vector-search/vector-search-overview/>` feature
26
+ in the {+driver-short+}. The ``Aggregates`` builders class provides the
27
+ the ``vectorSearch()`` helper method that you can use to
28
+ create a :atlas:`$vectorSearch </atlas-vector-search/vector-search-stage/>`
29
+ pipeline stage. This pipeline stage allows you to perform a **semantic
30
+ search** on your documents. A semantic search is a type of search which
31
+ locates information that is similar in meaning, but not necessarily
32
+ identical, to your provided search term or phrase.
33
+
34
+ .. important:: Feature Compatibility
35
+
36
+ To learn what versions of MongoDB Atlas support this feature, see
37
+ :atlas:`Limitations </atlas-vector-search/vector-search-stage/#limitations>`
38
+ in the MongoDB Atlas documentation.
39
+
40
+ Perform a Vector Search
41
+ -----------------------
42
+
43
+ To use this feature, you must create a vector search index and index your
44
+ vector embeddings. To learn about how to programmatically create a
45
+ vector search index, see the :ref:`java-search-indexes` section in the
46
+ Indexes guide. To learn more about vector embeddings, see
47
+ :atlas:`How to Index Vector Embeddings for Vector Search
48
+ </atlas-search/field-types/knn-vector/>` in the Atlas documentation.
49
+
50
+ After you create a vector search index on your vector embeddings, you
51
+ can reference this index in your pipeline stage, as shown in the
52
+ following section.
53
+
54
+ Vector Search Example
55
+ ~~~~~~~~~~~~~~~~~~~~~
56
+
57
+ The following example shows how to build an aggregation pipeline that uses the
58
+ ``vectorSearch()`` and ``project()`` methods to compute a vector search score:
59
+
60
+ .. literalinclude:: /includes/fundamentals/code-snippets/builders/AggBuilders.java
61
+ :start-after: // begin vectorSearch
62
+ :end-before: // end vectorSearch
63
+ :language: java
64
+ :dedent:
65
+
66
+ .. tip:: Query Vector Type
67
+
68
+ The preceding example creates an instance of ``BinaryVector`` to
69
+ serve as the query vector, but you can also create a ``List`` of
70
+ ``Double`` instances. However, we recommend that you use the
71
+ ``BinaryVector`` type to improve storage efficiency.
72
+
73
+ The following example shows how you can run the aggregation and print
74
+ the vector search meta-score from the result of the preceding
75
+ aggregation pipeline:
76
+
77
+ .. literalinclude:: /includes/fundamentals/code-snippets/builders/AggBuilders.java
78
+ :start-after: // begin vectorSearch-output
79
+ :end-before: // end vectorSearch-output
80
+ :language: java
81
+ :dedent:
82
+
83
+ .. tip:: Java Driver Vector Search Examples
84
+
85
+ Visit the :atlas:`Atlas documentation </atlas-vector-search/tutorials/>`
86
+ to find more tutorials on using the {+driver-short+} to perform Atlas
87
+ Vector Searches.
88
+
89
+ API Documentation
90
+ -----------------
91
+
92
+ To learn more about the methods and types mentioned in this
93
+ guide, see the following API documentation:
94
+
95
+ - `Aggregates.vectorSearch()
96
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Aggregates.html#vectorSearch(com.mongodb.client.model.search.FieldSearchPath,java.lang.Iterable,java.lang.String,long,com.mongodb.client.model.search.VectorSearchOptions)>`__
97
+
98
+ - `FieldSearchPath
99
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/search/FieldSearchPath.html>`__
100
+
101
+ - `VectorSearchOptions
102
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/search/VectorSearchOptions.html>`__
103
+
104
+ - `Projections.metaVectorSearchScore()
105
+ <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Projections.html#metaVectorSearchScore(java.lang.String)>`__
106
+
107
+ - `BinaryVector <{+api+}/apidocs/bson/org/bson/BinaryVector.html>`__
0 commit comments