@@ -1081,6 +1081,79 @@ public static PipelineDefinition<TInput, TOutput> RankFusion<TInput, TIntermedia
10811081 return pipeline . AppendStage ( PipelineStageDefinitionBuilder . RankFusion ( pipelinesWithWeights , options ) ) ;
10821082 }
10831083
1084+ /// <summary>
1085+ /// Appends a $rerank stage to the pipeline.
1086+ /// </summary>
1087+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1088+ /// <typeparam name="TField">The type of the field.</typeparam>
1089+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1090+ /// <param name="pipeline">The pipeline.</param>
1091+ /// <param name="query">The rerank query.</param>
1092+ /// <param name="path">The field to send to the reranker.</param>
1093+ /// <param name="numDocsToRerank">The maximum number of documents to rerank (1–1000).</param>
1094+ /// <param name="model">The reranking model name.</param>
1095+ /// <returns>A new pipeline with an additional stage.</returns>
1096+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TField , TOutput > (
1097+ this PipelineDefinition < TInput , TOutput > pipeline ,
1098+ RerankQuery query ,
1099+ Expression < Func < TOutput , TField > > path ,
1100+ int numDocsToRerank ,
1101+ string model )
1102+ {
1103+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1104+ return pipeline . AppendStage (
1105+ PipelineStageDefinitionBuilder . Rerank ( query , path , numDocsToRerank , model ) ,
1106+ pipeline . OutputSerializer ) ;
1107+ }
1108+
1109+ /// <summary>
1110+ /// Appends a $rerank stage to the pipeline.
1111+ /// </summary>
1112+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1113+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1114+ /// <param name="pipeline">The pipeline.</param>
1115+ /// <param name="query">The rerank query.</param>
1116+ /// <param name="path">The field to send to the reranker.</param>
1117+ /// <param name="numDocsToRerank">The maximum number of documents to rerank (1–1000).</param>
1118+ /// <param name="model">The reranking model name.</param>
1119+ /// <returns>A new pipeline with an additional stage.</returns>
1120+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TOutput > (
1121+ this PipelineDefinition < TInput , TOutput > pipeline ,
1122+ RerankQuery query ,
1123+ FieldDefinition < TOutput > path ,
1124+ int numDocsToRerank ,
1125+ string model )
1126+ {
1127+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1128+ return pipeline . AppendStage (
1129+ PipelineStageDefinitionBuilder . Rerank ( query , path , numDocsToRerank , model ) ,
1130+ pipeline . OutputSerializer ) ;
1131+ }
1132+
1133+ /// <summary>
1134+ /// Appends a $rerank stage to the pipeline.
1135+ /// </summary>
1136+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1137+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1138+ /// <param name="pipeline">The pipeline.</param>
1139+ /// <param name="query">The rerank query.</param>
1140+ /// <param name="paths">The fields to send to the reranker.</param>
1141+ /// <param name="numDocsToRerank">The maximum number of documents to rerank (1–1000).</param>
1142+ /// <param name="model">The reranking model name.</param>
1143+ /// <returns>A new pipeline with an additional stage.</returns>
1144+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TOutput > (
1145+ this PipelineDefinition < TInput , TOutput > pipeline ,
1146+ RerankQuery query ,
1147+ IEnumerable < FieldDefinition < TOutput > > paths ,
1148+ int numDocsToRerank ,
1149+ string model )
1150+ {
1151+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1152+ return pipeline . AppendStage (
1153+ PipelineStageDefinitionBuilder . Rerank ( query , paths , numDocsToRerank , model ) ,
1154+ pipeline . OutputSerializer ) ;
1155+ }
1156+
10841157 /// <summary>
10851158 /// Appends a $replaceRoot stage to the pipeline.
10861159 /// </summary>
0 commit comments