Skip to content

Commit a2f55a1

Browse files
committed
DOCSP-35724: documentation
1 parent 7f3efc0 commit a2f55a1

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

source/fundamentals/atlas-search.txt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ The following ``Guitar`` class models the documents in this collection.
5454
{
5555
public int Id { get; set; }
5656
public string Make { get; set; }
57-
public List<string> Models { get; set; }
57+
public List<string> Colors { get; set; }
5858
public int EstablishedYear { get; set; }
5959
[BsonElement("in_stock")]
6060
public bool InStock { get; set; }
@@ -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 that have field values matching 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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,17 @@ public static List<Guitar> GeoWithinSearch()
130130
return result;
131131
}
132132

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

0 commit comments

Comments
 (0)