forked from mongodb/mongo-csharp-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIAggregateFluent.cs
612 lines (556 loc) · 32.5 KB
/
IAggregateFluent.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver.Search;
namespace MongoDB.Driver
{
/// <summary>
/// Fluent interface for aggregate.
/// </summary>
/// <remarks>
/// This interface is not guaranteed to remain stable. Implementors should use
/// <see cref="AggregateFluentBase{TResult}" />.
/// </remarks>
/// <typeparam name="TResult">The type of the result of the pipeline.</typeparam>
public interface IAggregateFluent<TResult> : IAsyncCursorSource<TResult>
{
/// <summary>
/// Gets the database.
/// </summary>
IMongoDatabase Database { get; }
/// <summary>
/// Gets the options.
/// </summary>
AggregateOptions Options { get; }
/// <summary>
/// Gets the stages.
/// </summary>
IList<IPipelineStageDefinition> Stages { get; }
/// <summary>
/// Appends the stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the result of the stage.</typeparam>
/// <param name="stage">The stage.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> AppendStage<TNewResult>(PipelineStageDefinition<TResult, TNewResult> stage);
/// <summary>
/// Changes the result type of the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="newResultSerializer">The new result serializer.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> As<TNewResult>(IBsonSerializer<TNewResult> newResultSerializer = null);
/// <summary>
/// Appends a $bucket stage to the pipeline.
/// </summary>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="groupBy">The expression providing the value to group by.</param>
/// <param name="boundaries">The bucket boundaries.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<AggregateBucketResult<TValue>> Bucket<TValue>(
AggregateExpressionDefinition<TResult, TValue> groupBy,
IEnumerable<TValue> boundaries,
AggregateBucketOptions<TValue> options = null);
/// <summary>
/// Appends a $bucket stage to the pipeline with a custom projection.
/// </summary>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="groupBy">The expression providing the value to group by.</param>
/// <param name="boundaries">The bucket boundaries.</param>
/// <param name="output">The output projection.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> Bucket<TValue, TNewResult>(
AggregateExpressionDefinition<TResult, TValue> groupBy,
IEnumerable<TValue> boundaries,
ProjectionDefinition<TResult, TNewResult> output,
AggregateBucketOptions<TValue> options = null);
/// <summary>
/// Appends a $bucketAuto stage to the pipeline.
/// </summary>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="groupBy">The expression providing the value to group by.</param>
/// <param name="buckets">The number of buckets.</param>
/// <param name="options">The options (optional).</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<AggregateBucketAutoResult<TValue>> BucketAuto<TValue>(
AggregateExpressionDefinition<TResult, TValue> groupBy,
int buckets,
AggregateBucketAutoOptions options = null);
/// <summary>
/// Appends a $bucketAuto stage to the pipeline with a custom projection.
/// </summary>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="groupBy">The expression providing the value to group by.</param>
/// <param name="buckets">The number of buckets.</param>
/// <param name="output">The output projection.</param>
/// <param name="options">The options (optional).</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> BucketAuto<TValue, TNewResult>(
AggregateExpressionDefinition<TResult, TValue> groupBy,
int buckets,
ProjectionDefinition<TResult, TNewResult> output,
AggregateBucketAutoOptions options = null);
/// <summary>
/// Appends a $changeStream stage to the pipeline.
/// Normally you would prefer to use the Watch method of <see cref="IMongoCollection{TDocument}" />.
/// Only use this method if subsequent stages project away the resume token (the _id)
/// or you don't want the resulting cursor to automatically resume.
/// </summary>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<ChangeStreamDocument<TResult>> ChangeStream(ChangeStreamStageOptions options = null);
/// <summary>
/// Appends a count stage to the pipeline.
/// </summary>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<AggregateCountResult> Count();
/// <summary>
/// Appends a $densify stage to the pipeline.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="range">The range.</param>
/// <param name="partitionByFields">The fields to partition by.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Densify(
FieldDefinition<TResult> field,
DensifyRange range,
IEnumerable<FieldDefinition<TResult>> partitionByFields = null);
/// <summary>
/// Appends a $densify stage to the pipeline.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="range">The range.</param>
/// <param name="partitionByFields">The fields to partition by.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Densify(
FieldDefinition<TResult> field,
DensifyRange range,
params FieldDefinition<TResult>[] partitionByFields);
/// <summary>
/// Appends a $facet stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="facets">The facets.</param>
/// <param name="options">The options.</param>
/// <returns>
/// The fluent aggregate interface.
/// </returns>
IAggregateFluent<TNewResult> Facet<TNewResult>(
IEnumerable<AggregateFacet<TResult>> facets,
AggregateFacetOptions<TNewResult> options = null);
/// <summary>
/// Appends a $graphLookup stage to the pipeline.
/// </summary>
/// <typeparam name="TFrom">The type of the from documents.</typeparam>
/// <typeparam name="TConnectFrom">The type of the connect from field (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam>
/// <typeparam name="TConnectTo">The type of the connect to field.</typeparam>
/// <typeparam name="TStartWith">The type of the start with expression (must be either TConnectTo or a type that implements IEnumerable{TConnectTo}).</typeparam>
/// <typeparam name="TAsElement">The type of the as field elements.</typeparam>
/// <typeparam name="TAs">The type of the as field.</typeparam>
/// <typeparam name="TNewResult">The type of the new result (must be same as TResult with an additional as field).</typeparam>
/// <param name="from">The from collection.</param>
/// <param name="connectFromField">The connect from field.</param>
/// <param name="connectToField">The connect to field.</param>
/// <param name="startWith">The start with value.</param>
/// <param name="as">The as field.</param>
/// <param name="depthField">The depth field.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> GraphLookup<TFrom, TConnectFrom, TConnectTo, TStartWith, TAsElement, TAs, TNewResult>(
IMongoCollection<TFrom> from,
FieldDefinition<TFrom, TConnectFrom> connectFromField,
FieldDefinition<TFrom, TConnectTo> connectToField,
AggregateExpressionDefinition<TResult, TStartWith> startWith,
FieldDefinition<TNewResult, TAs> @as,
FieldDefinition<TAsElement, int> depthField,
AggregateGraphLookupOptions<TFrom, TAsElement, TNewResult> options = null)
where TAs : IEnumerable<TAsElement>;
/// <summary>
/// Appends a group stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the result of the stage.</typeparam>
/// <param name="group">The group projection.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> Group<TNewResult>(ProjectionDefinition<TResult, TNewResult> group);
/// <summary>
/// Appends a limit stage to the pipeline.
/// </summary>
/// <param name="limit">The limit.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Limit(long limit);
/// <summary>
/// Appends a lookup stage to the pipeline.
/// </summary>
/// <typeparam name="TForeignDocument">The type of the foreign document.</typeparam>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="foreignCollectionName">Name of the other collection.</param>
/// <param name="localField">The local field.</param>
/// <param name="foreignField">The foreign field.</param>
/// <param name="as">The field in <typeparamref name="TNewResult" /> to place the foreign results.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> Lookup<TForeignDocument, TNewResult>(string foreignCollectionName, FieldDefinition<TResult> localField, FieldDefinition<TForeignDocument> foreignField, FieldDefinition<TNewResult> @as, AggregateLookupOptions<TForeignDocument, TNewResult> options = null);
/// <summary>
/// Appends a lookup stage to the pipeline.
/// </summary>
/// <typeparam name="TForeignDocument">The type of the foreign collection documents.</typeparam>
/// <typeparam name="TAsElement">The type of the as field elements.</typeparam>
/// <typeparam name="TAs">The type of the as field.</typeparam>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="foreignCollection">The foreign collection.</param>
/// <param name="let">The "let" definition.</param>
/// <param name="lookupPipeline">The lookup pipeline.</param>
/// <param name="as">The as field in <typeparamref name="TNewResult" /> in which to place the results of the lookup pipeline.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> Lookup<TForeignDocument, TAsElement, TAs, TNewResult>(
IMongoCollection<TForeignDocument> foreignCollection,
BsonDocument let,
PipelineDefinition<TForeignDocument, TAsElement> lookupPipeline,
FieldDefinition<TNewResult, TAs> @as,
AggregateLookupOptions<TForeignDocument, TNewResult> options = null)
where TAs : IEnumerable<TAsElement>;
/// <summary>
/// Appends a match stage to the pipeline.
/// </summary>
/// <param name="filter">The filter.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Match(FilterDefinition<TResult> filter);
/// <summary>
/// Appends a merge stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <typeparam name="TOutput">The type of output documents.</typeparam>
/// <param name="outputCollection">The output collection.</param>
/// <param name="mergeOptions">The merge options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
IAsyncCursor<TOutput> Merge<TOutput>(IMongoCollection<TOutput> outputCollection, MergeStageOptions<TOutput> mergeOptions = null, CancellationToken cancellationToken = default);
/// <summary>
/// Appends a merge stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <typeparam name="TOutput">The type of output documents.</typeparam>
/// <param name="outputCollection">The output collection.</param>
/// <param name="mergeOptions">The merge options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
Task<IAsyncCursor<TOutput>> MergeAsync<TOutput>(IMongoCollection<TOutput> outputCollection, MergeStageOptions<TOutput> mergeOptions = null, CancellationToken cancellationToken = default);
/// <summary>
/// Appends a match stage to the pipeline that matches derived documents and changes the result type to the derived type.
/// </summary>
/// <typeparam name="TNewResult">The type of the derived documents.</typeparam>
/// <param name="newResultSerializer">The new result serializer.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> OfType<TNewResult>(IBsonSerializer<TNewResult> newResultSerializer = null) where TNewResult : TResult;
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="outputCollection">The output collection.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
IAsyncCursor<TResult> Out(IMongoCollection<TResult> outputCollection, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
IAsyncCursor<TResult> Out(string collectionName, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="outputCollection">The output collection.</param>
/// <param name="timeSeriesOptions">The time series options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
IAsyncCursor<TResult> Out(IMongoCollection<TResult> outputCollection, TimeSeriesOptions timeSeriesOptions, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="timeSeriesOptions">The time series options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A cursor.</returns>
IAsyncCursor<TResult> Out(string collectionName, TimeSeriesOptions timeSeriesOptions, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="outputCollection">The output collection.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A Task whose result is a cursor.</returns>
Task<IAsyncCursor<TResult>> OutAsync(IMongoCollection<TResult> outputCollection, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A Task whose result is a cursor.</returns>
Task<IAsyncCursor<TResult>> OutAsync(string collectionName, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="outputCollection">The output collection.</param>
/// <param name="timeSeriesOptions">The time series options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A Task whose result is a cursor.</returns>
Task<IAsyncCursor<TResult>> OutAsync(IMongoCollection<TResult> outputCollection, TimeSeriesOptions timeSeriesOptions, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an out stage to the pipeline and executes it, and then returns a cursor to read the contents of the output collection.
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="timeSeriesOptions">The time series options.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A Task whose result is a cursor.</returns>
Task<IAsyncCursor<TResult>> OutAsync(string collectionName, TimeSeriesOptions timeSeriesOptions, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends a project stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the result of the stage.</typeparam>
/// <param name="projection">The projection.</param>
/// <returns>
/// The fluent aggregate interface.
/// </returns>
IAggregateFluent<TNewResult> Project<TNewResult>(ProjectionDefinition<TResult, TNewResult> projection);
/// <summary>
/// Appends a $rankFusion stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="pipelines">The map of named pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
/// <param name="weights">The map of pipeline names to non-negative numerical weights determining result importance during combination. Default weight is 1 when unspecified.</param>
/// <param name="options">The rankFusion options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
Dictionary<string, PipelineDefinition<TResult, TNewResult>> pipelines,
Dictionary<string, double> weights = null,
RankFusionOptions<TNewResult> options = null);
/// <summary>
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="pipelines">The collection of pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
/// <param name="options">The rankFusion options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
PipelineDefinition<TResult, TNewResult>[] pipelines,
RankFusionOptions<TNewResult> options = null);
/// <summary>
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="pipelinesWithWeights">The collection of tuples containing (pipeline, weight) pairs. The pipelines must operate on the same collection.</param>
/// <param name="options">The rankFusion options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
(PipelineDefinition<TResult, TNewResult>, double?)[] pipelinesWithWeights,
RankFusionOptions<TNewResult> options = null);
/// <summary>
/// Appends a $replaceRoot stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="newRoot">The new root.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> ReplaceRoot<TNewResult>(AggregateExpressionDefinition<TResult, TNewResult> newRoot);
/// <summary>
/// Appends a $replaceWith stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="newRoot">The new root.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> ReplaceWith<TNewResult>(AggregateExpressionDefinition<TResult, TNewResult> newRoot);
/// <summary>
/// Appends a sample stage to the pipeline.
/// </summary>
/// <param name="size">The sample size.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Sample(long size);
/// <summary>
/// Appends a $set stage to the pipeline.
/// </summary>
/// <param name="fields">The fields to set.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Set(SetFieldDefinitions<TResult> fields);
/// <summary>
/// Appends a $setWindowFields to the pipeline.
/// </summary>
/// <typeparam name="TWindowFields">The type of the added window fields.</typeparam>
/// <param name="output">The window fields definition.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<BsonDocument> SetWindowFields<TWindowFields>(
AggregateExpressionDefinition<ISetWindowFieldsPartition<TResult>, TWindowFields> output);
//TODO If I add a parameter here, then this would be a binary breaking change
/// <summary>
/// Appends a $search stage to the pipeline.
/// </summary>
/// <param name="searchDefinition">The search definition.</param>
/// <param name="highlight">The highlight options.</param>
/// <param name="indexName">The index name.</param>
/// <param name="count">The count options.</param>
/// <param name="returnStoredSource">
/// Flag that specifies whether to perform a full document lookup on the backend database
/// or return only stored source fields directly from Atlas Search.
/// </param>
/// <param name="scoreDetails">
/// Flag that specifies whether to return a detailed breakdown
/// of the score for each document in the result.
/// </param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Search(
SearchDefinition<TResult> searchDefinition,
SearchHighlightOptions<TResult> highlight = null,
string indexName = null,
SearchCountOptions count = null,
bool returnStoredSource = false,
bool scoreDetails = false);
/// <summary>
/// Appends a $search stage to the pipeline.
/// </summary>
/// <param name="searchDefinition">The search definition.</param>
/// <param name="searchOptions">The search options.</param>
/// <returns>
/// The fluent aggregate interface.
/// </returns>
IAggregateFluent<TResult> Search(
SearchDefinition<TResult> searchDefinition,
SearchOptions<TResult> searchOptions);
/// <summary>
/// Appends a $searchMeta stage to the pipeline.
/// </summary>
/// <param name="searchDefinition">The search definition.</param>
/// <param name="indexName">The index name.</param>
/// <param name="count">The count options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<SearchMetaResult> SearchMeta(
SearchDefinition<TResult> searchDefinition,
string indexName = null,
SearchCountOptions count = null);
/// <summary>
/// Appends a $setWindowFields to the pipeline.
/// </summary>
/// <typeparam name="TPartitionBy">The type of the value to partition by.</typeparam>
/// <typeparam name="TWindowFields">The type of the added window fields.</typeparam>
/// <param name="partitionBy">The partitionBy definition.</param>
/// <param name="output">The window fields definition.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<BsonDocument> SetWindowFields<TPartitionBy, TWindowFields>(
AggregateExpressionDefinition<TResult, TPartitionBy> partitionBy,
AggregateExpressionDefinition<ISetWindowFieldsPartition<TResult>, TWindowFields> output);
/// <summary>
/// Appends a $setWindowFields to the pipeline.
/// </summary>
/// <typeparam name="TPartitionBy">The type of the value to partition by.</typeparam>
/// <typeparam name="TWindowFields">The type of the added window fields.</typeparam>
/// <param name="partitionBy">The partitionBy definition.</param>
/// <param name="sortBy">The sortBy definition.</param>
/// <param name="output">The window fields definition.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<BsonDocument> SetWindowFields<TPartitionBy, TWindowFields>(
AggregateExpressionDefinition<TResult, TPartitionBy> partitionBy,
SortDefinition<TResult> sortBy,
AggregateExpressionDefinition<ISetWindowFieldsPartition<TResult>, TWindowFields> output);
/// <summary>
/// Appends a skip stage to the pipeline.
/// </summary>
/// <param name="skip">The number of documents to skip.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Skip(long skip);
/// <summary>
/// Appends a sort stage to the pipeline.
/// </summary>
/// <param name="sort">The sort specification.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> Sort(SortDefinition<TResult> sort);
/// <summary>
/// Appends a sortByCount stage to the pipeline.
/// </summary>
/// <typeparam name="TId">The type of the identifier.</typeparam>
/// <param name="id">The identifier.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<AggregateSortByCountResult<TId>> SortByCount<TId>(AggregateExpressionDefinition<TResult, TId> id);
/// <summary>
/// Executes an aggregation pipeline that writes the results to a collection.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
void ToCollection(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Executes an aggregation pipeline that writes the results to a collection.
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A Task.</returns>
Task ToCollectionAsync(CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Appends an $unionWith stage to the pipeline.
/// </summary>
/// <typeparam name="TWith">The type of the with collection documents.</typeparam>
/// <param name="withCollection">The with collection.</param>
/// <param name="withPipeline">The with pipeline.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> UnionWith<TWith>(
IMongoCollection<TWith> withCollection,
PipelineDefinition<TWith, TResult> withPipeline = null);
/// <summary>
/// Appends an unwind stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the result of the stage.</typeparam>
/// <param name="field">The field.</param>
/// <param name="newResultSerializer">The new result serializer.</param>
/// <returns>
/// The fluent aggregate interface.
/// </returns>
[Obsolete("Use the Unwind overload which takes an options parameter.")]
IAggregateFluent<TNewResult> Unwind<TNewResult>(FieldDefinition<TResult> field, IBsonSerializer<TNewResult> newResultSerializer);
/// <summary>
/// Appends an unwind stage to the pipeline.
/// </summary>
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
/// <param name="field">The field.</param>
/// <param name="options">The options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TNewResult> Unwind<TNewResult>(FieldDefinition<TResult> field, AggregateUnwindOptions<TNewResult> options = null);
/// <summary>
/// Appends a vector search stage.
/// </summary>
/// <param name="field">The field.</param>
/// <param name="queryVector">The query vector.</param>
/// <param name="limit">The limit.</param>
/// <param name="options">The vector search options.</param>
/// <returns>The fluent aggregate interface.</returns>
IAggregateFluent<TResult> VectorSearch(
FieldDefinition<TResult> field,
QueryVector queryVector,
int limit,
VectorSearchOptions<TResult> options = null);
}
/// <summary>
/// Fluent interface for aggregate.
/// </summary>
/// <typeparam name="TResult">The type of the result.</typeparam>
public interface IOrderedAggregateFluent<TResult> : IAggregateFluent<TResult>
{
/// <summary>
/// Combines the current sort definition with an additional sort definition.
/// </summary>
/// <param name="newSort">The new sort.</param>
/// <returns>The fluent aggregate interface.</returns>
IOrderedAggregateFluent<TResult> ThenBy(SortDefinition<TResult> newSort);
}
}