Skip to content

Commit df1ec03

Browse files
committed
DOCSP-35724: $in operator documentation (#372)
(cherry picked from commit 0dc9837)
1 parent 50e8e97 commit df1ec03

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

source/fundamentals/atlas-search.txt

+22
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,28 @@ The search returns the following document:
335335
To learn more about the ``geoWithin`` operator, see the :atlas:`geoWithin </atlas-search/geoWithin>`
336336
Atlas guide.
337337

338+
In
339+
~~
340+
341+
Use the ``In()`` method to search for documents with field values that match a list
342+
of specified values.
343+
344+
The following example searches the ``guitars`` collection for documents that have a
345+
``make`` field value of either ``"Fender"`` or ``"Gibson"``.
346+
347+
.. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
348+
:start-after: start-in-search
349+
:end-before: end-in-search
350+
:language: csharp
351+
:dedent:
352+
353+
The search returns the following documents:
354+
355+
.. code-block:: json
356+
357+
{ "_id": 1, "make": "Fender", "description": "...", "establishedYear": 1946, "in_stock": true, "rating": 9 }
358+
{ "_id": 2, "make": "Gibson", "description": "...", "establishedYear": 1902, "in_stock": true, "rating": 8 }
359+
338360
MoreLikeThis
339361
~~~~~~~~~~~~
340362

source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs

+10
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,16 @@ public static List<Guitar> GeoWithinSearch()
130130
return result;
131131
}
132132

133+
public static List<Guitar> InSearch()
134+
{
135+
// start-in-search
136+
var result = guitarsCollection.Aggregate()
137+
.Search(Builders<Guitar>.Search.In(g => g.Make, ["Fender", "Gibson"]))
138+
.ToList();
139+
// end-in-search
140+
return result;
141+
}
142+
133143
public static List<Guitar> MoreLikeThisSearch()
134144
{
135145
// start-morelikethis-search

0 commit comments

Comments
 (0)