@@ -1316,7 +1316,6 @@ public static PipelineStageDefinition<TInput, TOutput> Project<TInput, TOutput>(
13161316 /// <param name="highlight">The highlight options.</param>
13171317 /// <param name="indexName">The index name.</param>
13181318 /// <param name="count">The count options.</param>
1319- /// <param name="sort">The sort specification.</param>
13201319 /// <param name="returnStoredSource">
13211320 /// Flag that specifies whether to perform a full document lookup on the backend database
13221321 /// or return only stored source fields directly from Atlas Search.
@@ -1331,9 +1330,31 @@ public static PipelineStageDefinition<TInput, TInput> Search<TInput>(
13311330 SearchHighlightOptions < TInput > highlight = null ,
13321331 string indexName = null ,
13331332 SearchCountOptions count = null ,
1334- SortDefinition < TInput > sort = null ,
13351333 bool returnStoredSource = false ,
13361334 bool scoreDetails = false )
1335+ {
1336+ var searchOptions = new SearchOptions < TInput > ( )
1337+ {
1338+ CountOptions = count ,
1339+ Highlight = highlight ,
1340+ IndexName = indexName ,
1341+ ReturnStoredSource = returnStoredSource ,
1342+ ScoreDetails = scoreDetails
1343+ } ;
1344+
1345+ return Search ( searchDefinition , searchOptions ) ;
1346+ }
1347+
1348+ /// <summary>
1349+ /// Creates a $search stage.
1350+ /// </summary>
1351+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1352+ /// <param name="searchDefinition">The search definition.</param>
1353+ /// <param name="searchOptions">The search options.</param>
1354+ /// <returns>The stage.</returns>
1355+ public static PipelineStageDefinition < TInput , TInput > Search < TInput > (
1356+ SearchDefinition < TInput > searchDefinition ,
1357+ SearchOptions < TInput > searchOptions )
13371358 {
13381359 Ensure . IsNotNull ( searchDefinition , nameof ( searchDefinition ) ) ;
13391360
@@ -1343,12 +1364,12 @@ public static PipelineStageDefinition<TInput, TInput> Search<TInput>(
13431364 ( s , sr , linqProvider ) =>
13441365 {
13451366 var renderedSearchDefinition = searchDefinition . Render ( s , sr ) ;
1346- renderedSearchDefinition . Add ( "highlight" , ( ) => highlight . Render ( s , sr ) , highlight != null ) ;
1347- renderedSearchDefinition . Add ( "count" , ( ) => count . Render ( ) , count != null ) ;
1348- renderedSearchDefinition . Add ( "sort" , ( ) => sort . Render ( s , sr ) , sort != null ) ;
1349- renderedSearchDefinition . Add ( "index" , indexName , indexName != null ) ;
1350- renderedSearchDefinition . Add ( "returnStoredSource" , returnStoredSource , returnStoredSource ) ;
1351- renderedSearchDefinition . Add ( "scoreDetails" , scoreDetails , scoreDetails ) ;
1367+ renderedSearchDefinition . Add ( "highlight" , ( ) => searchOptions . Highlight . Render ( s , sr ) , searchOptions . Highlight != null ) ;
1368+ renderedSearchDefinition . Add ( "count" , ( ) => searchOptions . CountOptions . Render ( ) , searchOptions . CountOptions != null ) ;
1369+ renderedSearchDefinition . Add ( "sort" , ( ) => searchOptions . Sort . Render ( s , sr ) , searchOptions . Sort != null ) ;
1370+ renderedSearchDefinition . Add ( "index" , searchOptions . IndexName , searchOptions . IndexName != null ) ;
1371+ renderedSearchDefinition . Add ( "returnStoredSource" , searchOptions . ReturnStoredSource , searchOptions . ReturnStoredSource ) ;
1372+ renderedSearchDefinition . Add ( "scoreDetails" , searchOptions . ScoreDetails , searchOptions . ScoreDetails ) ;
13521373
13531374 var document = new BsonDocument ( operatorName , renderedSearchDefinition ) ;
13541375 return new RenderedPipelineStageDefinition < TInput > ( operatorName , document , s ) ;
0 commit comments