Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 6 additions & 2 deletions source/fundamentals/builders.txt
Original file line number Diff line number Diff line change
Expand Up @@ -439,14 +439,17 @@ have a defined Atlas Vector Search index before you can perform a vector search
:atlas:`Create an Atlas Vector Search Index </atlas-vector-search/create-index>` in the
Atlas manual.

.. include:: /includes/vector-search-parameters.rst

Consider the ``embedded_movies`` collection in the ``sample_mflix`` database. 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 builders to generate an aggregation pipeline to
perform the following operations:

- Performs a vector search on the Atlas Vector Search index of the ``plot_embedding`` field using vector embeddings for the string ``"time travel"``
- Performs a vector search on the Atlas Vector Search index of the ``plot_embedding``
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be misleading to use plot_embedding here and m => m.Embedding in the code.
Maybe worth adding the EmbeddedMovie model for clarity.

field using vector embeddings for the string ``"time travel"``
- Fetches the ``Title`` and ``Plot`` fields from documents found in the vector search

.. code-block:: csharp
Expand Down Expand Up @@ -485,7 +488,8 @@ The results of the preceding example contain the following documents:
{ "_id" : ObjectId("573a13b6f29313caabd477fa"), "plot" : "With the help of his uncle, a man travels to the future to try and bring his girlfriend back to life.", "title" : "Love Story 2050" }
{ "_id" : ObjectId("573a13e5f29313caabdc40c9"), "plot" : "A dimension-traveling wizard gets stuck in the 21st century because cell-phone radiation interferes with his magic. With his home world on the brink of war, he seeks help from a jaded ...", "title" : "The Portal" }

To learn more about Atlas Vector Search, see :atlas:`Atlas Vector Search Overview </atlas-vector-search/vector-search-overview/>`
To learn more about Atlas Vector Search, see
:atlas:`Atlas Vector Search Overview </atlas-vector-search/vector-search-overview/>`
in the Atlas manual.

Additional Information
Expand Down
2 changes: 2 additions & 0 deletions source/fundamentals/linq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ defined Atlas Vector Search index before you can perform a vector search on your
:atlas:`Create an Atlas Vector Search Index </atlas-vector-search/create-index>` in the
Atlas manual.

.. include:: /includes/vector-search-parameters.rst

Consider the ``embedded_movies`` collection in the ``sample_mflix`` database. You
can use a ``$vectorSearch`` stage to perform a semantic search on the ``plot_embedding``
field of the documents in the collection.
Expand Down
68 changes: 68 additions & 0 deletions source/includes/vector-search-parameters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
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 floating-point numbers.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
array of floating-point numbers.
array of ``float`` numbers

S: Helpful to say the data type explicitly.


**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: 20 80

* - 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.

**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.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question for tech reviewer: What index is used if this param is empty?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It defaults to "default".


**Data type**: {+string-data-type+}
**Default**: ``null``

* - ``NumberOfCandidates``
- The number of neighbors to search in the index.

**Data type**: ``int?``
**Default**: ``null``
Loading