diff -puNr xapian-omega-1.0.8/omega.cc xapian-omega-1.0.8-sorter/omega.cc --- xapian-omega-1.0.8/omega.cc 2008-09-04 07:52:13.000000000 +0200 +++ xapian-omega-1.0.8-sorter/omega.cc 2008-09-16 14:25:42.000000000 +0200 @@ -72,6 +72,7 @@ bool sort_numeric = false; Xapian::valueno sort_key = Xapian::BAD_VALUENO; // Don't sort. bool sort_ascending = true; bool sort_after = false; +int sort_factor = 0; Xapian::Enquire::docid_order docid_order = Xapian::Enquire::ASCENDING; Xapian::valueno collapse_key = 0; @@ -330,6 +331,13 @@ try { if (val != cgi_params.end()) { sort_after = (atoi(val->second.c_str()) != 0); } + val = cgi_params.find("SORTFACTOR"); + if(val != cgi_params.end()) { + sort_factor = atoi(val->second.c_str()); + if(sort_factor > 10000 || sort_factor < 1) { + sort_factor = 0; + } + } // Add the sorting related options to filters too. filters += int_to_string(sort_key); if (sort_after) { diff -puNr xapian-omega-1.0.8/omega.h xapian-omega-1.0.8-sorter/omega.h --- xapian-omega-1.0.8/omega.h 2008-09-04 07:52:13.000000000 +0200 +++ xapian-omega-1.0.8-sorter/omega.h 2008-09-16 14:24:37.000000000 +0200 @@ -60,6 +60,7 @@ extern bool sort_numeric; extern Xapian::valueno sort_key; extern bool sort_ascending; extern bool sort_after; +extern int sort_factor; extern Xapian::Enquire::docid_order docid_order; extern Xapian::valueno collapse_key; diff -puNr xapian-omega-1.0.8/query.cc xapian-omega-1.0.8-sorter/query.cc --- xapian-omega-1.0.8/query.cc 2008-09-04 07:52:13.000000000 +0200 +++ xapian-omega-1.0.8-sorter/query.cc 2008-09-16 15:07:00.000000000 +0200 @@ -379,8 +379,12 @@ run_query() enquire->set_cutoff(threshold); + Xapian::RoundedWeightSorter * rwsorter; if (sort_key != Xapian::BAD_VALUENO) { - if (sort_after) { + if (sort_after && sort_factor) { + rwsorter = new Xapian::RoundedWeightSorter(sort_factor, sort_key, !sort_ascending); + enquire->set_sort_by_key(rwsorter); + } else if (sort_after) { enquire->set_sort_by_relevance_then_value(sort_key, sort_ascending); } else { enquire->set_sort_by_value_then_relevance(sort_key, sort_ascending);