-
Notifications
You must be signed in to change notification settings - Fork 43
DOCSP-45096: binaryvector type for avs #608
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
rustagir
merged 5 commits into
mongodb:master
from
rustagir:DOCSP-45096-vectorsearch-improved-api
Jan 13, 2025
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
.. _java-atlas-vector-search: | ||
|
||
=================== | ||
Atlas Vector Search | ||
=================== | ||
|
||
.. facet:: | ||
:name: genre | ||
:values: reference | ||
|
||
.. meta:: | ||
:keywords: code example, semantic, nearest | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 2 | ||
:class: singlecol | ||
|
||
Overview | ||
-------- | ||
|
||
In this guide, you can learn how to use the :atlas:`Atlas Vector Search | ||
</atlas-vector-search/vector-search-overview/>` feature | ||
in the {+driver-short+}. The ``Aggregates`` builders class provides the | ||
the ``vectorSearch()`` helper method that you can use to | ||
create a :atlas:`$vectorSearch </atlas-vector-search/vector-search-stage/>` | ||
pipeline stage. This pipeline stage allows you to perform a **semantic | ||
search** on your documents. A semantic search is a type of search which | ||
locates information that is similar in meaning, but not necessarily | ||
identical, to your provided search term or phrase. | ||
|
||
.. important:: Feature Compatibility | ||
|
||
To learn what versions of MongoDB Atlas support this feature, see | ||
:atlas:`Limitations </atlas-vector-search/vector-search-stage/#limitations>` | ||
in the MongoDB Atlas documentation. | ||
|
||
Perform a Vector Search | ||
----------------------- | ||
|
||
To use this feature, you must create a vector search index and index your | ||
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/>` in the Atlas documentation. | ||
|
||
After you create a vector search index on your vector embeddings, you | ||
can reference this index in your pipeline stage, as shown in the | ||
following section. | ||
|
||
Vector Search Example | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
The following example shows how to build an aggregation pipeline that uses the | ||
``vectorSearch()`` and ``project()`` methods to compute a vector search score: | ||
|
||
.. literalinclude:: /includes/fundamentals/code-snippets/builders/AggBuilders.java | ||
:start-after: // begin vectorSearch | ||
:end-before: // end vectorSearch | ||
:language: java | ||
:dedent: | ||
|
||
.. tip:: Query Vector Type | ||
|
||
The preceding example creates an instance of ``BinaryVector`` to | ||
serve as the query vector, but you can also create a ``List`` of | ||
``Double`` instances. However, we recommend that you use the | ||
``BinaryVector`` type to improve storage efficiency. | ||
|
||
The following example shows how you can run the aggregation and print | ||
the vector search meta-score from the result of the preceding | ||
aggregation pipeline: | ||
|
||
.. literalinclude:: /includes/fundamentals/code-snippets/builders/AggBuilders.java | ||
:start-after: // begin vectorSearch-output | ||
:end-before: // end vectorSearch-output | ||
:language: java | ||
:dedent: | ||
|
||
.. tip:: Java Driver Vector Search Examples | ||
|
||
Visit the :atlas:`Atlas documentation </atlas-vector-search/tutorials/>` | ||
to find more tutorials on using the {+driver-short+} to perform Atlas | ||
Vector Searches. | ||
|
||
API Documentation | ||
----------------- | ||
|
||
To learn more about the methods and types mentioned in this | ||
guide, see the following API documentation: | ||
|
||
- `Aggregates.vectorSearch() | ||
<{+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)>`__ | ||
|
||
- `FieldSearchPath | ||
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/search/FieldSearchPath.html>`__ | ||
|
||
- `VectorSearchOptions | ||
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/search/VectorSearchOptions.html>`__ | ||
|
||
- `Projections.metaVectorSearchScore() | ||
<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Projections.html#metaVectorSearchScore(java.lang.String)>`__ | ||
|
||
.. TODO add BinaryVector API link |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.