Skip to content

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

Open
wants to merge 12 commits into
base: docsp-45382-comp-cvg
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions source/aggregation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Aggregation Operations
:maxdepth: 1

Pipeline Stages </aggregation/stages>
LINQ </aggregation/linq>

Overview
--------
Expand Down
4 changes: 2 additions & 2 deletions source/aggregation/linq.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The {+driver-short+} automatically translates LINQ queries into
The examples in this guide use the ``restaurants`` collection
in the ``sample_restaurants`` database provided in the :atlas:`Atlas sample datasets </sample-data>`.
To learn how to create a free MongoDB Atlas cluster and load the sample datasets,
see the :ref:`<csharp-quickstart>`.
see :ref:`<csharp-get-started>`.

The following ``Restaurant``, ``Address`` and ``GradeEntry`` classes model the
documents in this collection:
Expand Down Expand Up @@ -1025,7 +1025,7 @@ aggregation stages:
- ``$out``

To learn how to create an aggregation pipeline with the ``$out`` stage by using Builders, see
the :ref:`<csharp-builders-out>` section.
:ref:`<csharp-aggregation-stages>`.

Supported Methods
-----------------
Expand Down
1 change: 0 additions & 1 deletion source/aggregation/stages.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.. _csharp-aggregation-stages:
.. _csharp-builders-aggregation:
.. _csharp-linq:

===========================
Aggregation Pipeline Stages
Expand Down
81 changes: 25 additions & 56 deletions source/atlas-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The examples in this guide use the following documents in a collection called
``guitars``:

.. code-block:: json

{ "_id": 1, "make": "Fender", "description": "Classic guitars known for their versatility.", "establishedYear": 1946, "in_stock": true, "rating": 9 }
{ "_id": 2, "make": "Gibson", "description": "Classic guitars known for their rich, full tones.", "establishedYear": 1902, "in_stock": true, "rating": 8 }
{ "_id": 3, "make": "PRS", "description": "High-end guitars known for their quality.", "establishedYear": 1985, "in_stock": true, "rating": 9 }
Expand Down Expand Up @@ -75,7 +75,7 @@ Create an Atlas Search Index

Before you can perform a search on an Atlas collection, you must first create an **Atlas
Search index** on the collection. An Atlas Search index is a data structure that
categorizes data in a searchable format.
categorizes data in a searchable format.

To learn how to create an Atlas Search Index see the
:atlas:`Create an Atlas Search Index </atlas-search/create-index>` Atlas guide.
Expand Down Expand Up @@ -103,7 +103,7 @@ collection using the string "Gib" in the ``make`` field.
:dedent:

.. note::

If the field you are searching on is indexed by a search index, you must pass the index name to the ``Autocomplete`` call. If a search index does not exist, the default index is used.

The search returns the following document:
Expand All @@ -112,7 +112,7 @@ The search returns the following document:

{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }

To learn more about the ``autocomplete`` operator, see the :atlas:`autocomplete </atlas-search/autocomplete>`
To learn more about the ``autocomplete`` operator, see the :atlas:`autocomplete </atlas-search/autocomplete>`
Atlas guide.

Compound
Expand Down Expand Up @@ -142,7 +142,7 @@ The search returns the following documents:
{ "_id" : 3, "make" : "PRS", "description" : "...", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
{ "_id" : 5, "make" : "Ibanez", "description" : "...", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }

To learn more about the ``compound`` operator, see the :atlas:`compound </atlas-search/compound>`
To learn more about the ``compound`` operator, see the :atlas:`compound </atlas-search/compound>`
Atlas guide.

EmbeddedDocument
Expand All @@ -153,7 +153,7 @@ within a field's array value.

.. note::

To search on embedded documents, you must create an
To search on embedded documents, you must create an
``embeddedDocument`` index on the array field.

To learn how to define an ``embeddedDocument`` index, see
Expand Down Expand Up @@ -218,7 +218,7 @@ The search returns the following documents:
{ "_id" : 5, "make" : "Ibanez", "description" : "...", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }


To learn more about the ``equals`` operator, see the :atlas:`equals </atlas-search/equals>`
To learn more about the ``equals`` operator, see the :atlas:`equals </atlas-search/equals>`
Atlas guide.

Exists
Expand Down Expand Up @@ -246,8 +246,7 @@ The search returns the following documents:
{ "_id" : 3, "make" : "PRS", "description" : "...", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
{ "_id" : 5, "make" : "Ibanez", "description" : "...", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }


To learn more about the ``exists`` operator, see the :atlas:`exists </atlas-search/exists>`
To learn more about the ``exists`` operator, see the :atlas:`exists </atlas-search/exists>`
Atlas guide.

GeoShape
Expand All @@ -266,7 +265,7 @@ Consider some documents in the ``guitars`` collection have added an
follows:

.. code-block:: json

{ "_id": 1, "make": "Fender", "description": "...", "establishedYear": 1946, "in_stock": true, "in_stock_location": { "type": "Point", "coordinates": [ -73.93615, 40.69791 ]}, "rating": 9 }
{ "_id": 2, "make": "Gibson", "description": "...", "establishedYear": 1902, "in_stock": true, "in_stock_location": { "type": "Point", "coordinates": [ 47.6062, 122.321 ]}, "rating": 8 }

Expand All @@ -286,7 +285,7 @@ The search returns the following document:

{ "_id" : 1, "make" : "Fender", "description" : "...", "establishedYear" : 1946, "in_stock" : true, "in_stock_location" : { "type" : "Point", "coordinates" : ["-73.93615", "40.69791"] }, "rating" : 9 }

To learn more about the ``geoShape`` operator, see the :atlas:`geoShape </atlas-search/geoShape>`
To learn more about the ``geoShape`` operator, see the :atlas:`geoShape </atlas-search/geoShape>`
Atlas guide.

GeoWithin
Expand All @@ -312,13 +311,13 @@ Consider some documents in the ``guitars`` collection have added an
follows:

.. code-block:: json

{ "_id": 1, "make": "Fender", "description": "...", "establishedYear": 1946, "in_stock": true, "in_stock_location": { "type": "Point", "coordinates": [ -73.93615, 40.69791 ]}, "rating": 9 }
{ "_id": 2, "make": "Gibson", "description": "...", "establishedYear": 1902, "in_stock": true, "in_stock_location": { "type": "Point", "coordinates": [ 47.6062, 122.321 ]}, "rating": 8 }

The following example searches for all documents in which the
coordinates in the ``in_stock_location`` field falls within a specified
polygon:
polygon:

.. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
:start-after: // start-geowithin-search
Expand All @@ -332,7 +331,7 @@ The search returns the following document:

{ "_id" : 1, "make" : "Fender", "description" : "Classic guitars known for their versatility.", "establishedYear" : 1946, "in_stock" : true, "in_stock_location" : { "type" : "Point", "coordinates" : ["-73.93615", "40.69791"] }, "rating" : 9 }

To learn more about the ``geoWithin`` operator, see the :atlas:`geoWithin </atlas-search/geoWithin>`
To learn more about the ``geoWithin`` operator, see the :atlas:`geoWithin </atlas-search/geoWithin>`
Atlas guide.

In
Expand Down Expand Up @@ -381,7 +380,7 @@ The search returns the following documents:
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }


To learn more about the ``moreLikeThis`` operator, see the :atlas:`moreLikeThis </atlas-search/morelikethis>`
To learn more about the ``moreLikeThis`` operator, see the :atlas:`moreLikeThis </atlas-search/morelikethis>`
Atlas guide.

Near
Expand Down Expand Up @@ -414,7 +413,7 @@ The search returns the following documents:
{ "_id" : 5, "make" : "Ibanez", "description" : "...", "establishedYear" : 1957, "in_stock" : true, "rating" : 7 }


To learn more about the ``near`` operator, see the :atlas:`near </atlas-search/near>`
To learn more about the ``near`` operator, see the :atlas:`near </atlas-search/near>`
Atlas guide.

Phrase
Expand Down Expand Up @@ -456,7 +455,7 @@ This search returns the following documents:
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }

To learn more about the ``phrase`` operator, see the :atlas:`phrase </atlas-search/phrase>`
To learn more about the ``phrase`` operator, see the :atlas:`phrase </atlas-search/phrase>`
Atlas guide.

QueryString
Expand All @@ -466,7 +465,7 @@ Use the ``QueryString()`` method to search for documents using a string with
the following operators and delimiters:

- ``AND``
- ``OR``
- ``OR``
- ``NOT``
- ``()``

Expand All @@ -490,7 +489,7 @@ The search returns the following documents:
{ "_id" : 3, "make" : "PRS", "description" : "High-end guitars known for their quality.", "establishedYear" : 1985, "in_stock" : true, "rating" : 9 }
{ "_id" : 2, "make" : "Gibson", "description" : "Classic guitars known for their rich, full tones.", "establishedYear" : 1902, "in_stock" : true, "rating" : 8 }

To learn more about the ``queryString`` operator, see the :atlas:`queryString </atlas-search/queryString>`
To learn more about the ``queryString`` operator, see the :atlas:`queryString </atlas-search/queryString>`
Atlas guide.

Range
Expand All @@ -516,7 +515,7 @@ The search returns the following results:
{ "_id" : 4, "make" : "Kiesel", "description" : "Quality guitars made only for custom orders.", "establishedYear" : 2015, "in_stock" : false, "rating" : null }
{ "_id" : 6, "make" : "Strandberg", "description" : "Modern guitars known for their headless models.", "establishedYear" : 1982, "in_stock" : false, "rating" : null }

To learn more about the ``range`` operator, see the :atlas:`range </atlas-search/range>`
To learn more about the ``range`` operator, see the :atlas:`range </atlas-search/range>`
Atlas guide.

Regex
Expand Down Expand Up @@ -558,7 +557,7 @@ The search returns the following results:
search results. To learn more, see :atlas:`regex Behavior
</atlas-search/regex/#behavior>`.

To learn more about the ``regex`` operator, see the :atlas:`regex </atlas-search/regex>`
To learn more about the ``regex`` operator, see the :atlas:`regex </atlas-search/regex>`
Atlas guide.

Span
Expand Down Expand Up @@ -593,7 +592,7 @@ Although the document with ``_id: 3`` contains the strings "guitars" and
"quality", they are separated by more than one word, so the search omits this
document from the results.

To learn more about the ``span`` operator, see the :atlas:`span </atlas-search/span>`
To learn more about the ``span`` operator, see the :atlas:`span </atlas-search/span>`
Atlas guide.

Text
Expand Down Expand Up @@ -624,7 +623,7 @@ The search returns the following document:
If your search string contains multiple terms, the method also looks for a match
for each term in the string separately.

To learn more about the ``text`` operator, see the :atlas:`text </atlas-search/text>`
To learn more about the ``text`` operator, see the :atlas:`text </atlas-search/text>`
Atlas guide.

Wildcard
Expand All @@ -640,7 +639,7 @@ characters in your search:

* - Character
- Description

* - ``?``
- Matches any single character

Expand Down Expand Up @@ -681,35 +680,5 @@ The search returns the following document:
search results. To learn more, see :atlas:`wildcard Behavior
</atlas-search/wildcard/#behavior>`.

To learn more about the ``wildcard`` operator, see the :atlas:`wildcard </atlas-search/wildcard>`
Atlas guide.

.. TODO: integrate into existing page

Sample Class
------------

The code examples in this guide demonstrate how you can use builders to
create types to interact with documents in the sample collection ``plants.flowers``.
Documents in this collection are modeled by the following ``Flower`` class:

.. literalinclude:: /includes/fundamentals/code-examples/builders.cs
:language: csharp
:dedent:
:start-after: start-model
:end-before: end-model

Each builder class takes a generic type parameter
``TDocument`` which represents the type of document that you are working
with. In this guide, the ``Flower`` class is the document type used in
each builder class example.

Build an Atlas Search Query
---------------------------

The ``Search`` class provides a type-safe interface for creating a
:manual:`$search </reference/operator/aggregation/search/>`
pipeline stage.

To learn how to construct search queries with the ``Search`` class, see
:ref:`csharp-atlas-search`.
To learn more about the ``wildcard`` operator, see the :atlas:`wildcard </atlas-search/wildcard>`
Atlas guide.
27 changes: 14 additions & 13 deletions source/atlas-vector-search.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
.. facet::
:name: genre
:values: reference

.. meta::
:keywords: semantic
:keywords: semantic

.. contents:: On this page
:local:
Expand Down Expand Up @@ -78,22 +78,23 @@
.VectorSearch(m => m.Embedding, vector, 10, options)
.Project(Builders<EmbeddedMovie>.Projection
.Include(m => m.Title)
.Include(m => m.Plot));
.Include(m => m.Plot)
.MetaVectorSearchScore(m => m.Score);

The results of the preceding example contain the following documents:

.. code-block:: json

{ "_id" : ObjectId("573a13a0f29313caabd04a4f"), "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers" }
{ "_id" : ObjectId("573a13d8f29313caabda6557"), "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time" }
{ "_id" : ObjectId("573a13a5f29313caabd13b4b"), "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine" }
{ "_id" : ObjectId("573a13aef29313caabd2e2d7"), "plot" : "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", "title" : "Crusade in Jeans" }
{ "_id" : ObjectId("573a1399f29313caabceec0e"), "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop" }
{ "_id" : ObjectId("573a1399f29313caabcee36f"), "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X." }
{ "_id" : ObjectId("573a13c6f29313caabd715d3"), "plot" : "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", "title" : "Men in Black 3" }
{ "_id" : ObjectId("573a13d4f29313caabd98c13"), "plot" : "Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.", "title" : "Tomorrowland" }
{ "_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" }
{ "_id" : { "$oid" : "573a13a0f29313caabd04a4f" }, "plot" : "A reporter, learning of time travelers visiting 20th century disasters, tries to change the history they know by averting upcoming disasters.", "title" : "Thrill Seekers", "score" : 0.926971435546875 }

Check failure on line 88 in source/atlas-vector-search.txt

View workflow job for this annotation

GitHub Actions / TDBX Vale rules

[vale] reported by reviewdog 🐶 [MongoDB.DatesOrdinal] Spell out all ordinal numbers ('20th'). For example, don’t use January 1st; use January 1 instead. Raw Output: {"message": "[MongoDB.DatesOrdinal] Spell out all ordinal numbers ('20th'). For example, don’t use January 1st; use January 1 instead.", "location": {"path": "source/atlas-vector-search.txt", "range": {"start": {"line": 88, "column": 113}}}, "severity": "ERROR"}
{ "_id" : { "$oid" : "573a13d8f29313caabda6557" }, "plot" : "At the age of 21, Tim discovers he can travel in time and change what happens and has happened in his own life. His decision to make his world a better place by getting a girlfriend turns out not to be as easy as you might think.", "title" : "About Time", "score" : 0. 9267120361328125 }
{ "_id" : { "$oid" : "573a1399f29313caabceec0e" }, "plot" : "An officer for a security agency that regulates time travel, must fend for his life against a shady politician who has a tie to his past.", "title" : "Timecop", "score" : 0.9235687255859375 }
{ "_id" : { "$oid" : "573a13a5f29313caabd13b4b" }, "plot" : "Hoping to alter the events of the past, a 19th century inventor instead travels 800,000 years into the future, where he finds humankind divided into two warring races.", "title" : "The Time Machine", "score" : 0.9228668212890625 }

Check failure on line 91 in source/atlas-vector-search.txt

View workflow job for this annotation

GitHub Actions / TDBX Vale rules

[vale] reported by reviewdog 🐶 [MongoDB.DatesOrdinal] Spell out all ordinal numbers ('19th'). For example, don’t use January 1st; use January 1 instead. Raw Output: {"message": "[MongoDB.DatesOrdinal] Spell out all ordinal numbers ('19th'). For example, don’t use January 1st; use January 1 instead.", "location": {"path": "source/atlas-vector-search.txt", "range": {"start": {"line": 91, "column": 107}}}, "severity": "ERROR"}
{ "_id" : { "$oid" : "573a13aef29313caabd2e2d7" }, "plot" : "After using his mother's newly built time machine, Dolf gets stuck involuntary in the year 1212. He ends up in a children's crusade where he confronts his new friends with modern techniques...", "title" : "Crusade in Jeans", "score" : 0.9228515625 }
{ "_id" : { "$oid" : "573a1399f29313caabcee36f" }, "plot" : "A time-travel experiment in which a robot probe is sent from the year 2073 to the year 1973 goes terribly wrong thrusting one of the project scientists, a man named Nicholas Sinclair into a...", "title" : "A.P.E.X.", "score" : 0.9199066162109375 }

Check failure on line 93 in source/atlas-vector-search.txt

View workflow job for this annotation

GitHub Actions / TDBX Vale rules

[vale] reported by reviewdog 🐶 [MongoDB.NegativeWords] Use 'incorrect, inconsistent' instead of the negative word 'wrong'. Raw Output: {"message": "[MongoDB.NegativeWords] Use 'incorrect, inconsistent' instead of the negative word 'wrong'.", "location": {"path": "source/atlas-vector-search.txt", "range": {"start": {"line": 93, "column": 171}}}, "severity": "ERROR"}
{ "_id" : { "$oid" : "573a13c6f29313caabd715d3" }, "plot" : "Agent J travels in time to M.I.B.'s early days in 1969 to stop an alien from assassinating his friend Agent K and changing history.", "title" : "Men in Black 3", "score" : 0.919403076171875 }
{ "_id" : { "$oid" : "573a13d4f29313caabd98c13" }, "plot" : "Bound by a shared destiny, a teen bursting with scientific curiosity and a former boy-genius inventor embark on a mission to unearth the secrets of a place somewhere in time and space that exists in their collective memory.", "title" : "Tomorrowland", "score" : 0.9191131591796875 }
{ "_id" : { "$oid" : "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", "score" : 0. 917755126953125 }
{ "_id" : { "$oid" : "573a13b3f29313caabd3ebd4" }, "plot" : "A romantic drama about a Chicago librarian with a gene that causes him to involuntarily time travel, and the complications it creates for his marriage.", "title" : "The Time Traveler's Wife", "score" : 0.9172210693359375 }

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