Skip to content

Commit 693ea35

Browse files
authoredMar 27, 2025
CSHARP-5541: move rankFusion methods to IAggregateFluentExtensions (#1648)
1 parent 34c1aa9 commit 693ea35

File tree

5 files changed

+57
-81
lines changed

5 files changed

+57
-81
lines changed
 

Diff for: ‎src/MongoDB.Driver/AggregateFluent.cs

-22
Original file line numberDiff line numberDiff line change
@@ -257,28 +257,6 @@ public override IAggregateFluent<TNewResult> Project<TNewResult>(ProjectionDefin
257257
return WithPipeline(_pipeline.Project(projection));
258258
}
259259

260-
public override IAggregateFluent<TNewResult> RankFusion<TNewResult>(
261-
Dictionary<string, PipelineDefinition<TResult, TNewResult>> pipelines,
262-
Dictionary<string, double> weights = null,
263-
RankFusionOptions<TNewResult> options = null)
264-
{
265-
return WithPipeline(_pipeline.RankFusion(pipelines, weights, options));
266-
}
267-
268-
public override IAggregateFluent<TNewResult> RankFusion<TNewResult>(
269-
PipelineDefinition<TResult, TNewResult>[] pipelines,
270-
RankFusionOptions<TNewResult> options = null)
271-
{
272-
return WithPipeline(_pipeline.RankFusion(pipelines, options));
273-
}
274-
275-
public override IAggregateFluent<TNewResult> RankFusion<TNewResult>(
276-
(PipelineDefinition<TResult, TNewResult>, double?)[] pipelinesWithWeights,
277-
RankFusionOptions<TNewResult> options = null)
278-
{
279-
return WithPipeline(_pipeline.RankFusion(pipelinesWithWeights, options));
280-
}
281-
282260
public override IAggregateFluent<TNewResult> ReplaceRoot<TNewResult>(AggregateExpressionDefinition<TResult, TNewResult> newRoot)
283261
{
284262
return WithPipeline(_pipeline.ReplaceRoot(newRoot));

Diff for: ‎src/MongoDB.Driver/AggregateFluentBase.cs

-23
Original file line numberDiff line numberDiff line change
@@ -225,29 +225,6 @@ public virtual Task<IAsyncCursor<TResult>> OutAsync(IMongoCollection<TResult> ou
225225
/// <inheritdoc />
226226
public abstract IAggregateFluent<TNewResult> Project<TNewResult>(ProjectionDefinition<TResult, TNewResult> projection);
227227

228-
/// <inheritdoc />
229-
public virtual IAggregateFluent<TNewResult> RankFusion<TNewResult>(
230-
Dictionary<string, PipelineDefinition<TResult, TNewResult>> pipelines,
231-
Dictionary<string, double> weights = null,
232-
RankFusionOptions<TNewResult> options = null)
233-
{
234-
throw new NotImplementedException();
235-
}
236-
237-
/// <inheritdoc />
238-
public virtual IAggregateFluent<TNewResult> RankFusion<TNewResult>(PipelineDefinition<TResult, TNewResult>[] pipelines, RankFusionOptions<TNewResult> options = null)
239-
{
240-
throw new NotImplementedException();
241-
}
242-
243-
/// <inheritdoc />
244-
public virtual IAggregateFluent<TNewResult> RankFusion<TNewResult>(
245-
(PipelineDefinition<TResult, TNewResult>, double?)[] pipelinesWithWeights,
246-
RankFusionOptions<TNewResult> options = null)
247-
{
248-
throw new NotImplementedException();
249-
}
250-
251228
/// <inheritdoc />
252229
public virtual IAggregateFluent<TNewResult> ReplaceRoot<TNewResult>(AggregateExpressionDefinition<TResult, TNewResult> newRoot)
253230
{

Diff for: ‎src/MongoDB.Driver/IAggregateFluent.cs

-35
Original file line numberDiff line numberDiff line change
@@ -365,41 +365,6 @@ IAggregateFluent<TNewResult> Lookup<TForeignDocument, TAsElement, TAs, TNewResul
365365
/// </returns>
366366
IAggregateFluent<TNewResult> Project<TNewResult>(ProjectionDefinition<TResult, TNewResult> projection);
367367

368-
/// <summary>
369-
/// Appends a $rankFusion stage to the pipeline.
370-
/// </summary>
371-
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
372-
/// <param name="pipelines">The map of named pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
373-
/// <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>
374-
/// <param name="options">The rankFusion options.</param>
375-
/// <returns>The fluent aggregate interface.</returns>
376-
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
377-
Dictionary<string, PipelineDefinition<TResult, TNewResult>> pipelines,
378-
Dictionary<string, double> weights = null,
379-
RankFusionOptions<TNewResult> options = null);
380-
381-
/// <summary>
382-
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
383-
/// </summary>
384-
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
385-
/// <param name="pipelines">The collection of pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
386-
/// <param name="options">The rankFusion options.</param>
387-
/// <returns>The fluent aggregate interface.</returns>
388-
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
389-
PipelineDefinition<TResult, TNewResult>[] pipelines,
390-
RankFusionOptions<TNewResult> options = null);
391-
392-
/// <summary>
393-
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
394-
/// </summary>
395-
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
396-
/// <param name="pipelinesWithWeights">The collection of tuples containing (pipeline, weight) pairs. The pipelines must operate on the same collection.</param>
397-
/// <param name="options">The rankFusion options.</param>
398-
/// <returns>The fluent aggregate interface.</returns>
399-
IAggregateFluent<TNewResult> RankFusion<TNewResult>(
400-
(PipelineDefinition<TResult, TNewResult>, double?)[] pipelinesWithWeights,
401-
RankFusionOptions<TNewResult> options = null);
402-
403368
/// <summary>
404369
/// Appends a $replaceRoot stage to the pipeline.
405370
/// </summary>

Diff for: ‎src/MongoDB.Driver/IAggregateFluentExtensions.cs

+56
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,62 @@ public static IAggregateFluent<TNewResult> Project<TResult, TNewResult>(this IAg
563563
return aggregate.AppendStage(PipelineStageDefinitionBuilder.Project(projection));
564564
}
565565

566+
/// <summary>
567+
/// Appends a $rankFusion stage to the pipeline.
568+
/// </summary>
569+
/// <typeparam name="TResult">The type of the result.</typeparam>
570+
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
571+
/// <param name="aggregate">The aggregate.</param>
572+
/// <param name="pipelines">The map of named pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
573+
/// <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>
574+
/// <param name="options">The rankFusion options.</param>
575+
/// <returns>The fluent aggregate interface.</returns>
576+
public static IAggregateFluent<TNewResult> RankFusion<TResult, TNewResult>(
577+
this IAggregateFluent<TResult> aggregate,
578+
Dictionary<string, PipelineDefinition<TResult, TNewResult>> pipelines,
579+
Dictionary<string, double> weights = null,
580+
RankFusionOptions<TNewResult> options = null)
581+
{
582+
Ensure.IsNotNull(aggregate, nameof(aggregate));
583+
return aggregate.AppendStage(PipelineStageDefinitionBuilder.RankFusion(pipelines, weights, options));
584+
}
585+
586+
/// <summary>
587+
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
588+
/// </summary>
589+
/// <typeparam name="TResult">The type of the result.</typeparam>
590+
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
591+
/// <param name="aggregate">The aggregate.</param>
592+
/// <param name="pipelines">The collection of pipelines whose results will be combined. The pipelines must operate on the same collection.</param>
593+
/// <param name="options">The rankFusion options.</param>
594+
/// <returns>The fluent aggregate interface.</returns>
595+
public static IAggregateFluent<TNewResult> RankFusion<TResult, TNewResult>(
596+
this IAggregateFluent<TResult> aggregate,
597+
PipelineDefinition<TResult, TNewResult>[] pipelines,
598+
RankFusionOptions<TNewResult> options = null)
599+
{
600+
Ensure.IsNotNull(aggregate, nameof(aggregate));
601+
return aggregate.AppendStage(PipelineStageDefinitionBuilder.RankFusion(pipelines, options));
602+
}
603+
604+
/// <summary>
605+
/// Appends a $rankFusion stage to the pipeline. Pipelines will be automatically named as "pipeline1", "pipeline2", etc.
606+
/// </summary>
607+
/// <typeparam name="TResult">The type of the result.</typeparam>
608+
/// <typeparam name="TNewResult">The type of the new result.</typeparam>
609+
/// <param name="aggregate">The aggregate.</param>
610+
/// <param name="pipelinesWithWeights">The collection of tuples containing (pipeline, weight) pairs. The pipelines must operate on the same collection.</param>
611+
/// <param name="options">The rankFusion options.</param>
612+
/// <returns>The fluent aggregate interface.</returns>
613+
public static IAggregateFluent<TNewResult> RankFusion<TResult, TNewResult>(
614+
this IAggregateFluent<TResult> aggregate,
615+
(PipelineDefinition<TResult, TNewResult>, double?)[] pipelinesWithWeights,
616+
RankFusionOptions<TNewResult> options = null)
617+
{
618+
Ensure.IsNotNull(aggregate, nameof(aggregate));
619+
return aggregate.AppendStage(PipelineStageDefinitionBuilder.RankFusion(pipelinesWithWeights, options));
620+
}
621+
566622
/// <summary>
567623
/// Appends a $replaceRoot stage to the pipeline.
568624
/// </summary>

Diff for: ‎src/MongoDB.Driver/Search/RankFusionScoreDetails.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public sealed class RankFusionScoreDetails
3030
/// <param name="value">The computed score which is the same as the score available via {$meta: "score"}.</param>
3131
/// <param name="description">Description of how the score was computed.</param>
3232
/// <param name="details">Info about how each input pipeline in the rankFusion stage contributed to the computed score.</param>
33-
/// <seealso cref="IAggregateFluent{TResult}.RankFusion{TNewResult}(Dictionary{string,PipelineDefinition{TResult,TNewResult}}, Dictionary{string,double}, RankFusionOptions{TNewResult})"/>
33+
/// <seealso cref="IAggregateFluentExtensions.RankFusion{TResult, TNewResult}(IAggregateFluent{TResult}, Dictionary{string,PipelineDefinition{TResult,TNewResult}}, Dictionary{string,double}, RankFusionOptions{TNewResult})"/>
3434
public RankFusionScoreDetails(double value, string description, BsonDocument[] details)
3535
{
3636
Value = value;

0 commit comments

Comments
 (0)
Please sign in to comment.