-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: docsp-45382-comp-cvg
Are you sure you want to change the base?
DOCSP-49786 - Projection methods #644
Conversation
✅ Deploy Preview for docs-csharp ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
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.
There are a bunch of white space changes included in this PR, which is fine, but I wanted to call it out in case they're not intended.
A few things to look at:
source/atlas-vector-search.txt
Outdated
{ "_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 } | ||
{ "_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 } | ||
{ "_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 } | ||
{ "_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 } |
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.
There's some extra spacing in the plot
and title
strings that I don't think is intentional.
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.
no, that's just how it pasted in from Rider. removed
source/crud/query/project.txt
Outdated
1. Use the ``Builders<TDocument>.Projection`` static property to create a | ||
``ProjectionDefinitionBuilder<TDocument>`` object. The ``ProjectionDefinitionBuilder`` class | ||
provides a type-safe interface for defining a projection. ``TDocument`` represents the | ||
C# class that the collection's documents map to. |
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.
Not strictly necessary, but I think this reads better:
1. Use the ``Builders<TDocument>.Projection`` static property to create a | |
``ProjectionDefinitionBuilder<TDocument>`` object. The ``ProjectionDefinitionBuilder`` class | |
provides a type-safe interface for defining a projection. ``TDocument`` represents the | |
C# class that the collection's documents map to. | |
1. Use the ``Builders<TDocument>.Projection`` static property to create a | |
``ProjectionDefinitionBuilder<TDocument>`` object, where ``TDocument`` represents the | |
C# class that the collection's documents map to. The ``ProjectionDefinitionBuilder`` class | |
provides a type-safe interface for defining a projection. |
source/crud/query/project.txt
Outdated
The ``Slice()`` method specifies the number of elements in an array to return in the query | ||
result. This is equivalent to using the ``$slice`` operator in the {+query-api+}. | ||
|
||
The following code example uses the ``Slice()`` method to return the first three elements | ||
of the ``cast`` array in the returned document: |
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.
This needs a tech review, but I think it's worth nit picking lists vs arrays in this case:
The ``Slice()`` method specifies the number of elements in an array to return in the query | |
result. This is equivalent to using the ``$slice`` operator in the {+query-api+}. | |
The following code example uses the ``Slice()`` method to return the first three elements | |
of the ``cast`` array in the returned document: | |
The ``Slice()`` method specifies the number of elements of a list or array to return in the query | |
result field. This is equivalent to using the ``$slice`` operator in the {+query-api+}. | |
The following code example uses the ``Slice()`` method to return the first three elements | |
of the ``Cast`` list in the returned document's ``cast`` array: |
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.
that's fair. Server only works with arrays and that's where I copied the text from
source/crud/query/project.txt
Outdated
To return elements from the end of an array, pass a negative integer to the ``Slice()`` | ||
method. The method returns the specified number of elements from the end of the array. | ||
The following code example returns the last three elements of the ``cast`` array in the | ||
returned document: |
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.
To return elements from the end of an array, pass a negative integer to the ``Slice()`` | |
method. The method returns the specified number of elements from the end of the array. | |
The following code example returns the last three elements of the ``cast`` array in the | |
returned document: | |
To return elements from the end of a collection, pass a negative integer to the ``Slice()`` | |
method. | |
The following code example returns the last three elements of the ``Cast`` list in the | |
returned document's ``cast`` array: |
source/crud/query/project.txt
Outdated
To skip a specified number of elements in the array, pass the number of elements to skip | ||
as the first parameter and the number of elements to return as the second | ||
parameter. The following code example skips the first element in the | ||
``cast`` array and returns the next three elements: |
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.
To skip a specified number of elements in the array, pass the number of elements to skip | |
as the first parameter and the number of elements to return as the second | |
parameter. The following code example skips the first element in the | |
``cast`` array and returns the next three elements: | |
To skip a specified number of elements in a collection, pass the number of elements to skip | |
as the first parameter and the number of elements to return as the second | |
parameter. The following code example skips the first element in the | |
``Cast`` list and returns the next three elements in the ``cast`` array: |
source/crud/query/project.txt
Outdated
The following code example projects each document's search score in a property named | ||
``Score``: |
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.
The following code example projects each document's search score in a property named | |
``Score``: | |
The following code example projects each document's search score in a property named | |
``score``: |
MetaTextScore | ||
~~~~~~~~~~~~~ |
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.
This is the only meta method with the Atlas only admonition - not sure if it's missing or if this can be applied to all searches?
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.
my understanding--and this might change during tech review--is that textScore
is the only metadata field that you can retrieve from a search on a local deployment. But i think you can also use it in Atlas Search
source/crud/query/project.txt
Outdated
To retrieve score details, you must create a ``SearchOptions`` object that, set its | ||
``ScoreDetails`` property to ``true``, and then pass this object to the ``Search()`` method. | ||
The following code example shows this process by projecting each document's search score | ||
details in a property named ``ScoreDetails``: |
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 found this a bit confusing because the property name and projection name were the same. Maybe change the projection name so it's clear they're distinct?
To retrieve score details, you must create a ``SearchOptions`` object that, set its | |
``ScoreDetails`` property to ``true``, and then pass this object to the ``Search()`` method. | |
The following code example shows this process by projecting each document's search score | |
details in a property named ``ScoreDetails``: | |
To retrieve score details, create a ``SearchOptions`` object with its | |
``ScoreDetails`` property set to ``true``, and then pass this object to the ``Search()`` method. | |
The following code example shows this process by projecting each document's search score | |
details in a property named ``SearchScoreDetails``: |
The ``Expression()`` method lets you specify the structure of the returned documents | ||
by using a lambda expression. This is equivalent to specifying the structure of the | ||
returned documents in the ``$project`` aggregation stage in the {+query-api+}. |
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 couldn't find the Expression()
, Include()
, or Exclude()
examples on this page - are they maybe not merged yet?
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.
yep, those examples will be missing until https://github.com/10gen/docs-mongodb-internal/pull/11902 is through external review
A lot of this will be incorporated into the Server/Atlas docs eventually, but that's out of scope for this ticket
Pull Request Info
PR Reviewing Guidelines
JIRA - https://jira.mongodb.org/browse/DOCSP-NNNNN
Staging Links
Self-Review Checklist