@@ -48,18 +48,11 @@ The examples in this guide use the following documents in a collection called
4848
4949The following ``Guitar`` class models the documents in this collection.
5050
51- .. code-block:: csharp
52-
53- public class Guitar
54- {
55- public int Id { get; set; }
56- public string Make { get; set; }
57- public List<string> Models { get; set; }
58- public int EstablishedYear { get; set; }
59- [BsonElement("in_stock")]
60- public bool InStock { get; set; }
61- public int? Rating { get; set; }
62- }
51+ .. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
52+ :start-after: // start-guitar-class
53+ :end-before: // end-guitar-class
54+ :language: csharp
55+ :dedent:
6356
6457.. note::
6558
@@ -683,3 +676,116 @@ The search returns the following document:
683676
684677To learn more about the ``wildcard`` operator, see the :atlas:`wildcard </atlas-search/wildcard>`
685678Atlas guide.
679+
680+ Modify Atlas Search Behavior
681+ ----------------------------
682+
683+ You can modify the behavior of the ``Search()`` method by passing
684+ a ``SearchOptions`` object as a parameter.
685+
686+ The ``SearchOptions`` class contains the following properties:
687+
688+ .. list-table::
689+ :widths: 30 70
690+ :header-rows: 1
691+
692+ * - Property
693+ - Description
694+
695+ * - ``CountOptions``
696+ - | The options for counting the search results.
697+
698+ | **Data type**: `SearchCountOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchCountOptions.html>`__
699+ | **Default**: ``null``
700+
701+ * - ``Highlight``
702+ - | The options for displaying search terms in their original context.
703+
704+ | **Data type**: `SearchHighlightOptions<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchHighlightOptions-1.html>`__
705+ | **Default**: ``null``
706+
707+ * - ``IndexName``
708+ - | The index to use for the search.
709+
710+ | **Data type**: {+string-data-type+}
711+ | **Default**: ``null``
712+
713+ * - ``ReturnStoredSource``
714+ - | A flag that specifies whether to perform a full document lookup on
715+ the database or to return only stored source fields directly from
716+ Atlas Search.
717+
718+ | **Data type**: {+bool-data-type+}
719+ | **Default**: ``false``
720+
721+ * - ``ScoreDetails``
722+ - | A flag that specifies whether to return detailed information about the
723+ score for each document in the results.
724+
725+ | **Data type**: {+bool-data-type+}
726+ | **Default**: ``false``
727+
728+ * - ``SearchAfter``
729+ - | The starting point for pagination. When set, the search retrieves documents
730+ starting immediately after the specified reference point.
731+
732+ | **Data type**: {+string-data-type+}
733+ | **Default**: ``null``
734+
735+ * - ``SearchBefore``
736+ - | The end point for pagination. When set, the search retrieves documents
737+ starting immediately before the specified reference point.
738+
739+ | **Data type**: {+string-data-type+}
740+ | **Default**: ``null``
741+
742+ * - ``Sort``
743+ - | The sorting criteria to apply to the results.
744+
745+ | **Data type**: `SortDefinition<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.SortDefinition-1.html>`__
746+ | **Default**: ``null``
747+
748+ * - ``Tracking``
749+ - | The options for tracking search terms.
750+
751+ | **Data type**: `SearchTrackingOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchTrackingOptions.html>`__
752+ | **Default**: ``null``
753+
754+ SearchAfter Example
755+ ~~~~~~~~~~~~~~~~~~~
756+
757+ The following example paginates the results of an Atlas Search
758+ operation by performing the following actions:
759+
760+ - Defines a projection that uses the ``MetaSearchSequenceToken()``
761+ builder method, which specifies a ``PaginationToken`` to contain
762+ the point of reference
763+
764+ - Creates a ``SearchOptions`` instance and sets the index and sort
765+ criteria to use
766+
767+ - Runs an initial search to find documents that have a ``description`` field value containing
768+ the text ``"classic"``, applying the projection and options to the operation
769+
770+ - Sets the ``SearchAfter`` property of the same ``SearchOptions`` instance to
771+ instruct the next search to begin after the base search's first result
772+
773+ - Runs another search operation that has the same matching criteria and applies
774+ the search options to paginate the results
775+
776+ .. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
777+ :start-after: // start-pagination-options
778+ :end-before: // end-pagination-options
779+ :language: csharp
780+ :dedent:
781+
782+ The search returns the following document:
783+
784+ .. code-block:: json
785+
786+ { "_id": 2, "make": "Gibson", "description": "Classic guitars known for their rich, full tones.", "establishedYear": 1902, "in_stock": true, "rating": 8 }
787+
788+ .. tip::
789+
790+ To learn more about Atlas Search pagination, see :atlas:`Paginate the Results </atlas-search/paginate-results/>`
791+ in the Atlas documentation.
0 commit comments