@@ -48,18 +48,11 @@ The examples in this guide use the following documents in a collection called
48
48
49
49
The following ``Guitar`` class models the documents in this collection.
50
50
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:
63
56
64
57
.. note::
65
58
@@ -709,3 +702,116 @@ The search returns the following document:
709
702
710
703
To learn more about the ``wildcard`` operator, see the :atlas:`wildcard </atlas-search/wildcard>`
711
704
Atlas guide.
705
+
706
+ Modify Atlas Search Behavior
707
+ ----------------------------
708
+
709
+ You can modify the behavior of the ``Search()`` method by passing
710
+ a ``SearchOptions`` object as a parameter.
711
+
712
+ The ``SearchOptions`` class contains the following properties:
713
+
714
+ .. list-table::
715
+ :widths: 30 70
716
+ :header-rows: 1
717
+
718
+ * - Property
719
+ - Description
720
+
721
+ * - ``CountOptions``
722
+ - | The options for counting the search results.
723
+
724
+ | **Data type**: `SearchCountOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchCountOptions.html>`__
725
+ | **Default**: ``null``
726
+
727
+ * - ``Highlight``
728
+ - | The options for displaying search terms in their original context.
729
+
730
+ | **Data type**: `SearchHighlightOptions<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchHighlightOptions-1.html>`__
731
+ | **Default**: ``null``
732
+
733
+ * - ``IndexName``
734
+ - | The index to use for the search.
735
+
736
+ | **Data type**: {+string-data-type+}
737
+ | **Default**: ``null``
738
+
739
+ * - ``ReturnStoredSource``
740
+ - | A flag that specifies whether to perform a full document lookup on
741
+ the database or to return only stored source fields directly from
742
+ Atlas Search.
743
+
744
+ | **Data type**: {+bool-data-type+}
745
+ | **Default**: ``false``
746
+
747
+ * - ``ScoreDetails``
748
+ - | A flag that specifies whether to return detailed information about the
749
+ score for each document in the results.
750
+
751
+ | **Data type**: {+bool-data-type+}
752
+ | **Default**: ``false``
753
+
754
+ * - ``SearchAfter``
755
+ - | The starting point for pagination. When set, the search retrieves documents
756
+ starting immediately after the specified reference point.
757
+
758
+ | **Data type**: {+string-data-type+}
759
+ | **Default**: ``null``
760
+
761
+ * - ``SearchBefore``
762
+ - | The end point for pagination. When set, the search retrieves documents
763
+ starting immediately before the specified reference point.
764
+
765
+ | **Data type**: {+string-data-type+}
766
+ | **Default**: ``null``
767
+
768
+ * - ``Sort``
769
+ - | The sorting criteria to apply to the results.
770
+
771
+ | **Data type**: `SortDefinition<TDocument> <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.SortDefinition-1.html>`__
772
+ | **Default**: ``null``
773
+
774
+ * - ``Tracking``
775
+ - | The options for tracking search terms.
776
+
777
+ | **Data type**: `SearchTrackingOptions <{+new-api-root+}/MongoDB.Driver/MongoDB.Driver.Search.SearchTrackingOptions.html>`__
778
+ | **Default**: ``null``
779
+
780
+ SearchAfter Example
781
+ ~~~~~~~~~~~~~~~~~~~
782
+
783
+ The following example paginates the results of an Atlas Search
784
+ operation by performing the following actions:
785
+
786
+ - Defines a projection that uses the ``MetaSearchSequenceToken()``
787
+ builder method, which specifies a ``PaginationToken`` to contain
788
+ the point of reference
789
+
790
+ - Creates a ``SearchOptions`` instance and sets the index and sort
791
+ criteria to use
792
+
793
+ - Runs an initial search to find documents that have a ``description`` field value containing
794
+ the text ``"classic"``, applying the projection and options to the operation
795
+
796
+ - Sets the ``SearchAfter`` property of the same ``SearchOptions`` instance to
797
+ instruct the next search to begin after the base search's first result
798
+
799
+ - Runs another search operation that has the same matching criteria and applies
800
+ the search options to paginate the results
801
+
802
+ .. literalinclude:: /includes/fundamentals/code-examples/atlas-search/AtlasSearchExamples.cs
803
+ :start-after: // start-pagination-options
804
+ :end-before: // end-pagination-options
805
+ :language: csharp
806
+ :dedent:
807
+
808
+ The search returns the following document:
809
+
810
+ .. code-block:: json
811
+
812
+ { "_id": 2, "make": "Gibson", "description": "Classic guitars known for their rich, full tones.", "establishedYear": 1902, "in_stock": true, "rating": 8 }
813
+
814
+ .. tip::
815
+
816
+ To learn more about Atlas Search pagination, see :atlas:`Paginate the Results </atlas-search/paginate-results/>`
817
+ in the Atlas documentation.
0 commit comments