diff --git a/source/fundamentals/atlas-search.txt b/source/fundamentals/atlas-search.txt index 23b19e72..4dae38c5 100644 --- a/source/fundamentals/atlas-search.txt +++ b/source/fundamentals/atlas-search.txt @@ -335,6 +335,28 @@ The search returns the following document: To learn more about the ``geoWithin`` operator, see the :atlas:`geoWithin ` Atlas guide. +In +~~ + +Use the ``In()`` method to search for documents with field values that match a list +of specified values. + +The following example searches the ``guitars`` collection for documents that have a +``make`` field value of either ``"Fender"`` or ``"Gibson"``. + +.. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs + :start-after: start-in-search + :end-before: end-in-search + :language: csharp + :dedent: + +The search returns the following documents: + +.. code-block:: json + + { "_id": 1, "make": "Fender", "description": "...", "establishedYear": 1946, "in_stock": true, "rating": 9 } + { "_id": 2, "make": "Gibson", "description": "...", "establishedYear": 1902, "in_stock": true, "rating": 8 } + MoreLikeThis ~~~~~~~~~~~~ diff --git a/source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs b/source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs index d53915fa..01279255 100644 --- a/source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs +++ b/source/includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs @@ -130,6 +130,16 @@ public static List GeoWithinSearch() return result; } + public static List InSearch() + { + // start-in-search + var result = guitarsCollection.Aggregate() + .Search(Builders.Search.In(g => g.Make, ["Fender", "Gibson"])) + .ToList(); + // end-in-search + return result; + } + public static List MoreLikeThisSearch() { // start-morelikethis-search