-
Notifications
You must be signed in to change notification settings - Fork 26
DOCSP-49786 - Projection methods #644
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
mongoKart
merged 14 commits into
mongodb:docsp-45382-comp-cvg
from
mongoKart:docsp-49786-meta-operator
Jul 1, 2025
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b03f346
first draft
mongoKart 01c89a6
add missing file
mongoKart 6c63bd6
build fixes
mongoKart 6db6276
build fix
mongoKart f78313a
Merge remote-tracking branch 'upstream/docsp-45382-comp-cvg' into doc…
mongoKart f07726c
add output examples
mongoKart a027cd1
update code file
mongoKart 3bc0624
hide output
mongoKart 091cdb6
rm feedback
mongoKart 6220d9e
rm feedback
mongoKart 809dd33
broken link
mongoKart 9cb1311
build errors
mongoKart 59ebf89
add camel case note
mongoKart 6876d1f
Merge branch 'docsp-45382-comp-cvg' into docsp-49786-meta-operator
mongoKart 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
add missing file
- Loading branch information
commit 01c89a66f6c90238b6e75455eabed11125908157
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| The ``$vectorSearch`` aggregation stage performs an *approximate nearest neighbor* search | ||
| on a vector in the specified field. Your collection *must* have a | ||
| defined Atlas Vector Search index before you can perform a vector search on your data. | ||
|
|
||
| .. tip:: | ||
|
|
||
| To obtain the sample dataset used in the following example, see :ref:`csharp-quickstart`. | ||
| To create the sample Atlas Vector Search index used in the following example, see | ||
| :atlas:`Create an Atlas Vector Search Index </atlas-vector-search/create-index>` in the | ||
| Atlas manual. | ||
|
|
||
| To create a ``$vectorSearch`` pipeline stage, call the ``VectorSearch()`` method on a | ||
| ``PipelineStageDefinitionBuilder`` object. The ``VectorSearch()`` method accepts the | ||
| following parameters: | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 20 80 | ||
|
|
||
| * - Parameter | ||
| - Description | ||
|
|
||
| * - ``field`` | ||
| - The field to perform the vector search on. | ||
|
|
||
| **Data type**: ``Expression<Func<TInput, TField>>`` | ||
|
|
||
| * - ``queryVector`` | ||
| - The encoded vector that will be matched with values from the database. | ||
| Although the data type of this parameter is ``QueryVector``, you can also pass an | ||
| array of ``float`` values. | ||
|
|
||
| **Data type**: `QueryVector <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.QueryVector.html>`__ | ||
|
|
||
| * - ``limit`` | ||
| - The maximum number of documents to return. | ||
|
|
||
| **Data type**: {+int-data-type+} | ||
|
|
||
| * - ``options`` | ||
| - Configuration options for the vector search operation. | ||
|
|
||
| **Data type**: `VectorSearchOptions<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.VectorSearchOptions-1.html>`__ | ||
|
|
||
| You can use the ``options`` parameter to configure your vector search operation. The | ||
| ``VectorSearchOptions`` class contains the following properties: | ||
|
|
||
| .. list-table:: | ||
| :header-rows: 1 | ||
| :widths: 30 70 | ||
|
|
||
| * - Property | ||
| - Description | ||
|
|
||
| * - ``Exact`` | ||
| - Whether the vector search uses the exact nearest neighbor (ENN) algorithm. | ||
| If this property is set to ``false``, the vector search uses the approximate nearest | ||
| neighbor (ANN) algorithm. If this property is set to ``true``, the | ||
| ``NumberOfCandidates`` property must be ``null``. | ||
|
|
||
| | **Data type**: {+bool-data-type+} | ||
| | **Default**: ``false`` | ||
|
|
||
| * - ``Filter`` | ||
| - Additional search criteria that the found documents must match. | ||
|
|
||
| | **Data Type:** `FilterDefinition<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.FilterDefinition-1.html>`__ | ||
| | **Default**: ``null`` | ||
|
|
||
| * - ``IndexName`` | ||
| - The index to perform the vector search on. | ||
|
|
||
| | **Data type**: {+string-data-type+} | ||
| | **Default**: ``null`` | ||
|
|
||
| * - ``NumberOfCandidates`` | ||
| - The number of neighbors to search in the index. | ||
|
|
||
| | **Data type**: ``int?`` | ||
| | **Default**: ``null`` | ||
|
|
||
| Consider the ``embedded_movies`` collection in the ``sample_mflix`` database. | ||
| The following ``EmbeddedMovie`` class represents a document in this database: | ||
|
|
||
| .. code-block:: csharp | ||
|
|
||
| public class EmbeddedMovie | ||
| { | ||
| [BsonElement("title")] | ||
| public string Title { get; set; } | ||
|
|
||
| [BsonElement("plot_embedding")] | ||
| public double[] Embedding { get; set; } | ||
|
|
||
| [BsonElement("score")] | ||
| public double Score { get; set; } | ||
| } | ||
|
|
||
| You can use a ``$vectorSearch`` stage to perform a semantic search on the ``plot_embedding`` | ||
| field of the documents in the collection. | ||
| The following example shows how to use |mechanism| to generate an aggregation pipeline to | ||
| perform the following operations: | ||
|
|
||
| - Perform a vector search on the Atlas Vector Search index of the ``plot_embedding`` | ||
| field by using vector embeddings for the string ``"time travel"`` | ||
| - Fetch the ``Title`` and ``Plot`` fields from documents found in the vector search |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked this file out from upstream/master. It doesn't need to be reviewed.