Andrey Kong
2006-Dec-09 02:50 UTC
[Xapian-discuss] Sorting set_sort_by_relevance_then_value
Hi I want to set_sort_by_relevance_then_value(0), but seems it doesnt work (PHP) $db = new XapianWritableDatabase("fullIndex3", DB_OPEN); $op_or = XapianQuery::OP_OR; $terms = array("google" ,"yahoo"); $enq = new XapianEnquire($db); $query=new XapianQuery($op_or, $terms); $enq->set_sort_by_relevance_then_value(0); $enq->set_query($query); $mset = $enq->get_mset(0, 50); am i doing wrong? i also tried to replace with set_docid_order() , still dosnt work too.. Thx Andrey K.
Olly Betts
2006-Dec-09 04:03 UTC
[Xapian-discuss] Sorting set_sort_by_relevance_then_value
On Sat, Dec 09, 2006 at 10:45:53AM +0800, Andrey Kong wrote:> I want to set_sort_by_relevance_then_value(0), but seems it doesnt work (PHP) > > $db = new XapianWritableDatabase("fullIndex3", DB_OPEN); > $op_or = XapianQuery::OP_OR; > $terms = array("google" ,"yahoo"); > $enq = new XapianEnquire($db); > > $query=new XapianQuery($op_or, $terms); > $enq->set_sort_by_relevance_then_value(0); > $enq->set_query($query);The documentation for Enquire::set_sort_by_relevance_then_value() says: Note that with the default BM25 weighting scheme parameters, non-identical documents will rarely have the same weight, so this setting will give very similar results to set_sort_by_relevance(). It becomes more useful with particular BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom weighting schemes. Your example uses the default BM25 parameters, so this applies to you. Try printing out the *differences* between the weights of adjacent documents in the MSet (just printing out the weights will probably show them as the same, but that's just because you aren't seeing all the significant figures). The default BM25 parameters which Xapian uses include the normalised document length in calculations. Documents are usually different lengths so it's rare for two documents to get the exact same weight.> i also tried to replace with set_docid_order() , still dosnt work too..The same thing applies. Cheers, Olly