@@ -1081,6 +1081,104 @@ 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.</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="TField">The type of the field.</typeparam>
1114+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1115+ /// <param name="pipeline">The pipeline.</param>
1116+ /// <param name="query">The rerank query.</param>
1117+ /// <param name="numDocsToRerank">The maximum number of documents to rerank.</param>
1118+ /// <param name="model">The reranking model name.</param>
1119+ /// <param name="paths">The fields to send to the reranker.</param>
1120+ /// <returns>A new pipeline with an additional stage.</returns>
1121+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TField , TOutput > (
1122+ this PipelineDefinition < TInput , TOutput > pipeline ,
1123+ RerankQuery query ,
1124+ int numDocsToRerank ,
1125+ string model ,
1126+ params Expression < Func < TOutput , TField > > [ ] paths )
1127+ {
1128+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1129+ return pipeline . AppendStage (
1130+ PipelineStageDefinitionBuilder . Rerank ( query , numDocsToRerank , model , paths ) ,
1131+ pipeline . OutputSerializer ) ;
1132+ }
1133+
1134+ /// <summary>
1135+ /// Appends a $rerank stage to the pipeline.
1136+ /// </summary>
1137+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1138+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1139+ /// <param name="pipeline">The pipeline.</param>
1140+ /// <param name="query">The rerank query.</param>
1141+ /// <param name="path">The field to send to the reranker.</param>
1142+ /// <param name="numDocsToRerank">The maximum number of documents to rerank.</param>
1143+ /// <param name="model">The reranking model name.</param>
1144+ /// <returns>A new pipeline with an additional stage.</returns>
1145+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TOutput > (
1146+ this PipelineDefinition < TInput , TOutput > pipeline ,
1147+ RerankQuery query ,
1148+ FieldDefinition < TOutput > path ,
1149+ int numDocsToRerank ,
1150+ string model )
1151+ {
1152+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1153+ return pipeline . AppendStage (
1154+ PipelineStageDefinitionBuilder . Rerank ( query , path , numDocsToRerank , model ) ,
1155+ pipeline . OutputSerializer ) ;
1156+ }
1157+
1158+ /// <summary>
1159+ /// Appends a $rerank stage to the pipeline.
1160+ /// </summary>
1161+ /// <typeparam name="TInput">The type of the input documents.</typeparam>
1162+ /// <typeparam name="TOutput">The type of the output documents.</typeparam>
1163+ /// <param name="pipeline">The pipeline.</param>
1164+ /// <param name="query">The rerank query.</param>
1165+ /// <param name="paths">The fields to send to the reranker.</param>
1166+ /// <param name="numDocsToRerank">The maximum number of documents to rerank.</param>
1167+ /// <param name="model">The reranking model name.</param>
1168+ /// <returns>A new pipeline with an additional stage.</returns>
1169+ public static PipelineDefinition < TInput , TOutput > Rerank < TInput , TOutput > (
1170+ this PipelineDefinition < TInput , TOutput > pipeline ,
1171+ RerankQuery query ,
1172+ IEnumerable < FieldDefinition < TOutput > > paths ,
1173+ int numDocsToRerank ,
1174+ string model )
1175+ {
1176+ Ensure . IsNotNull ( pipeline , nameof ( pipeline ) ) ;
1177+ return pipeline . AppendStage (
1178+ PipelineStageDefinitionBuilder . Rerank ( query , paths , numDocsToRerank , model ) ,
1179+ pipeline . OutputSerializer ) ;
1180+ }
1181+
10841182 /// <summary>
10851183 /// Appends a $replaceRoot stage to the pipeline.
10861184 /// </summary>
0 commit comments