Exemplo n.º 1
0
 def test_rank_fusion(self):
     treestr = '{"$and": [{"reading": {"$gte": 0.1}}, {"teaching_or_training": {"$gte": 0.1}}, {"$or": [{"research": {"$gte": 0.05}}, {"eating": {"$gte": 0.2}}]}]}'
     tree = json.loads(treestr)
     print tree
     qt = RankFusionQueryTree(tree, debug=True)
     results = qt.sql()
     print "Result = ", results
     self.assertEqual(results,"SELECT v_id, reading, teaching_or_training, research, eating, MAX( ( RANK() OVER (ORDER BY reading), RANK() OVER (ORDER BY teaching_or_training), RANK() OVER (ORDER BY MAX(research,eating)) ) ) as result FROM clip_calib_scores  ORDER BY result ASC LIMIT 0,50;")