@@ -196,7 +196,9 @@ def test_basic_reciprocal_rank(self):
196196 {"$unwind" : {"path" : "$docs" , "includeArrayIndex" : "rank" }},
197197 {
198198 "$addFields" : {
199- "docs.text_score" : {"$divide" : [1.0 , {"$add" : ["$rank" , 0 , 1 ]}]},
199+ "docs.text_score" : {
200+ "$multiply" : [1 , {"$divide" : [1.0 , {"$add" : ["$rank" , 0 , 1 ]}]}]
201+ },
200202 "docs.rank" : "$rank" ,
201203 "_id" : "$docs._id" ,
202204 }
@@ -210,7 +212,7 @@ def test_reciprocal_rank_with_penalty(self):
210212 result = reciprocal_rank_stage (score_field = "vector_score" , penalty = 60 )
211213
212214 add_fields_stage = result [2 ]["$addFields" ]
213- divide_expr = add_fields_stage ["docs.vector_score" ]["$divide" ]
215+ divide_expr = add_fields_stage ["docs.vector_score" ]["$multiply" ][ 1 ][ "$ divide" ]
214216 add_expr = divide_expr [1 ]["$add" ]
215217
216218 assert add_expr == ["$rank" , 60 , 1 ]
@@ -225,7 +227,11 @@ def test_reciprocal_rank_with_kwargs(self):
225227 result = reciprocal_rank_stage (score_field = "test_score" , penalty = 10 , extra_param = "ignored" )
226228
227229 assert len (result ) == 4
228- assert result [2 ]["$addFields" ]["docs.test_score" ]["$divide" ][1 ]["$add" ] == ["$rank" , 10 , 1 ]
230+ assert result [2 ]["$addFields" ]["docs.test_score" ]["$multiply" ][1 ]["$divide" ][1 ]["$add" ] == [
231+ "$rank" ,
232+ 10 ,
233+ 1 ,
234+ ]
229235
230236
231237class TestFinalHybridStage :
0 commit comments