Ticket #216: calcpercent.patch
File calcpercent.patch, 25.7 KB (added by , 17 years ago) |
---|
-
xapian-core/matcher/multimatch.cc
5 5 * Copyright 2002,2003,2004,2005,2006,2007,2008 Olly Betts 6 6 * Copyright 2003 Orange PCS Ltd 7 7 * Copyright 2003 Sam Liddicott 8 * Copyright 2007 Lemur Consulting Ltd8 * Copyright 2007,2008 Lemur Consulting Ltd 9 9 * 10 10 * This program is free software; you can redistribute it and/or 11 11 * modify it under the terms of the GNU General Public License as … … 180 180 const Xapian::RSet * omrset, 181 181 Xapian::valueno collapse_key_, 182 182 int percent_cutoff_, Xapian::weight weight_cutoff_, 183 bool need_percentages_, 183 184 Xapian::Enquire::docid_order order_, 184 185 Xapian::valueno sort_key_, 185 186 Xapian::Enquire::Internal::sort_setting sort_by_, … … 190 191 const Xapian::Weight * weight_) 191 192 : db(db_), query(query_), 192 193 collapse_key(collapse_key_), percent_cutoff(percent_cutoff_), 193 weight_cutoff(weight_cutoff_), order(order_), 194 weight_cutoff(weight_cutoff_), 195 need_percentages(need_percentages_), 196 order(order_), 194 197 sort_key(sort_key_), sort_by(sort_by_), 195 198 sort_value_forward(sort_value_forward_), sorter(sorter_), 196 199 errorhandler(errorhandler_), weight(weight_), … … 224 227 is_remote[i] = true; 225 228 rem_db->set_query(query, qlen, collapse_key, order, sort_key, 226 229 sort_by, sort_value_forward, percent_cutoff, 227 weight_cutoff, weight, subrsets[i]); 230 weight_cutoff, need_percentages, weight, 231 subrsets[i]); 228 232 bool decreasing_relevance = 229 233 (sort_by == REL || sort_by == REL_VAL); 230 234 smatch = new RemoteSubMatch(rem_db, decreasing_relevance); … … 423 427 matches_estimated, 424 428 max_weight, greatest_wt, items, 425 429 termfreqandwts, 426 0 ));430 0, false)); 427 431 return; 428 432 } 429 433 … … 455 459 // Minimum weight an item must have to be worth considering. 456 460 Xapian::weight min_weight = weight_cutoff; 457 461 462 Assert(percent_cutoff == 0 || need_percentages); 458 463 Xapian::weight percent_factor = percent_cutoff / 100.0; 459 464 460 465 // Table of keys which have been seen already, for collapsing. … … 773 778 delete pl; 774 779 775 780 double percent_scale = 0; 776 if (!items.empty() && greatest_wt > 0) { 777 // Find the document with the highest weight, then total up the 778 // weights for the terms it contains 779 vector<Xapian::Internal::MSetItem>::const_iterator best; 780 best = min_element(items.begin(), items.end(), mcmp); 781 if (need_percentages) { 782 if (!items.empty() && greatest_wt > 0) { 783 // Find the document with the highest weight, then total up the 784 // weights for the terms it contains 785 vector<Xapian::Internal::MSetItem>::const_iterator best; 786 best = min_element(items.begin(), items.end(), mcmp); 781 787 782 if (termfreqandwts.size() > 1) {783 784 785 Xapian::MSet::Internal::TermFreqAndWeight>::const_iterator i;788 if (termfreqandwts.size() > 1) { 789 Xapian::termcount matching_terms = 0; 790 map<string, 791 Xapian::MSet::Internal::TermFreqAndWeight>::const_iterator i; 786 792 787 Xapian::TermIterator docterms = db.termlist_begin(best->did); 788 Xapian::TermIterator docterms_end = db.termlist_end(best->did); 789 while (docterms != docterms_end) { 790 i = termfreqandwts.find(*docterms); 793 Xapian::TermIterator docterms = db.termlist_begin(best->did); 794 Xapian::TermIterator docterms_end = db.termlist_end(best->did); 795 while (docterms != docterms_end) { 796 i = termfreqandwts.find(*docterms); 797 if (i != termfreqandwts.end()) { 798 percent_scale += i->second.termweight; 799 ++matching_terms; 800 if (matching_terms == termfreqandwts.size()) break; 801 } 802 ++docterms; 803 } 804 // Special case for MatchAll queries 805 i = termfreqandwts.find(""); 791 806 if (i != termfreqandwts.end()) { 792 807 percent_scale += i->second.termweight; 793 808 ++matching_terms; 794 if (matching_terms == termfreqandwts.size()) break;795 809 } 796 ++docterms; 797 } 798 // Special case for MatchAll queries 799 i = termfreqandwts.find(""); 800 if (i != termfreqandwts.end()) { 801 percent_scale += i->second.termweight; 802 ++matching_terms; 803 } 804 if (matching_terms < termfreqandwts.size()) { 805 // OK, work out weight corresponding to 100% 806 double denom = 0; 807 for (i = termfreqandwts.begin(); i != termfreqandwts.end(); ++i) 808 denom += i->second.termweight; 810 if (matching_terms < termfreqandwts.size()) { 811 // OK, work out weight corresponding to 100% 812 double denom = 0; 813 for (i = termfreqandwts.begin(); i != termfreqandwts.end(); ++i) 814 denom += i->second.termweight; 809 815 810 DEBUGLINE(MATCH, "denom = " << denom << " percent_scale = " << percent_scale); 811 Assert(percent_scale <= denom); 812 denom *= greatest_wt; 813 Assert(denom > 0); 814 percent_scale /= denom; 816 DEBUGLINE(MATCH, "denom = " << denom << " percent_scale = " << percent_scale); 817 Assert(percent_scale <= denom); 818 denom *= greatest_wt; 819 Assert(denom > 0); 820 percent_scale /= denom; 821 } else { 822 // If all the terms match, the 2 sums of weights cancel 823 percent_scale = 1.0 / greatest_wt; 824 } 815 825 } else { 816 // If all the terms match, the 2 sums of weights cancel 826 // If there's only a single term in the query, the top document 827 // must score 100%. 817 828 percent_scale = 1.0 / greatest_wt; 818 829 } 819 } else { 820 // If there's only a single term in the query, the top document 821 // must score 100%. 822 percent_scale = 1.0 / greatest_wt; 823 } 824 Assert(percent_scale > 0); 825 if (percent_cutoff) { 826 // FIXME: better to sort and binary chop maybe? we 827 // could use the sort above to find "best" too. 828 // Or we could just use a linear scan here instead. 830 Assert(percent_scale > 0); 831 if (percent_cutoff) { 832 // FIXME: better to sort and binary chop maybe? we 833 // could use the sort above to find "best" too. 834 // Or we could just use a linear scan here instead. 829 835 830 831 832 833 is_heap = true;834 make_heap<vector<Xapian::Internal::MSetItem>::iterator,835 MSetCmp>(items.begin(), items.end(), mcmp);836 837 838 pop_heap<vector<Xapian::Internal::MSetItem>::iterator,839 MSetCmp>(items.begin(), items.end(), mcmp);840 Assert(items.back().wt < min_wt);841 items.pop_back();842 836 // trim the mset to the correct answer... 837 Xapian::weight min_wt = percent_factor / percent_scale; 838 if (!is_heap) { 839 is_heap = true; 840 make_heap<vector<Xapian::Internal::MSetItem>::iterator, 841 MSetCmp>(items.begin(), items.end(), mcmp); 842 } 843 while (!items.empty() && items.front().wt < min_wt) { 844 pop_heap<vector<Xapian::Internal::MSetItem>::iterator, 845 MSetCmp>(items.begin(), items.end(), mcmp); 846 Assert(items.back().wt < min_wt); 847 items.pop_back(); 848 } 843 849 #ifdef XAPIAN_DEBUG_PARANOID 844 vector<Xapian::Internal::MSetItem>::const_iterator j; 845 for (j = items.begin(); j != items.end(); ++j) { 846 Assert(j->wt >= min_wt); 850 vector<Xapian::Internal::MSetItem>::const_iterator j; 851 for (j = items.begin(); j != items.end(); ++j) { 852 Assert(j->wt >= min_wt); 853 } 854 #endif 847 855 } 848 #endif 856 percent_scale *= 100.0; 849 857 } 850 percent_scale *= 100.0;851 858 } 852 859 853 860 DEBUGLINE(MATCH, … … 997 1004 !collapse_tab.empty()) { 998 1005 // Nicked this formula from above, but for some reason percent_scale 999 1006 // has since been multiplied by 100 so we take that into account 1000 Xapian::weight min_wt = percent_factor / (percent_scale / 100); 1007 Xapian::weight min_wt = need_percentages ? 0.0 : 1008 percent_factor / (percent_scale / 100); 1001 1009 vector<Xapian::Internal::MSetItem>::iterator i; 1002 1010 for (i = items.begin(); i != items.end() && !collapse_tab.empty(); ++i) { 1003 1011 // Is this a collapsed hit? … … 1030 1038 matches_estimated, 1031 1039 max_weight, greatest_wt, items, 1032 1040 termfreqandwts, 1033 percent_scale)); 1041 percent_scale, 1042 need_percentages)); 1034 1043 } 1035 1044 1036 1045 // This method is called by branch postlists when they rebalance -
xapian-core/matcher/localmatch.cc
3 3 * Copyright 1999,2000,2001 BrightStation PLC 4 4 * Copyright 2002 Ananova Ltd 5 5 * Copyright 2002,2003,2004,2005,2006,2007,2008 Olly Betts 6 * Copyright 2007 Lemur Consulting Ltd6 * Copyright 2007,2008 Lemur Consulting Ltd 7 7 * 8 8 * This program is free software; you can redistribute it and/or 9 9 * modify it under the terms of the GNU General Public License as … … 117 117 double factor) 118 118 { 119 119 DEBUGCALL(MATCH, PostList *, "LocalSubMatch::postlist_from_op_leaf_query", 120 query << ", " << factor);120 query->get_description() << ", " << factor); 121 121 Assert(query); 122 122 AssertEq(query->op, Xapian::Query::Internal::OP_LEAF); 123 123 Assert(query->subqs.empty()); … … 140 140 Xapian::doccount tf = stats->get_termfreq(query->tname); 141 141 Xapian::weight weight = boolean ? 0 : wt->get_maxpart(); 142 142 Xapian::MSet::Internal::TermFreqAndWeight info(tf, weight); 143 DEBUGLINE(MATCH, "Setting term_info[" << query->tname << "] to (" << tf << ", " << weight << ")"); 143 144 term_info.insert(make_pair(query->tname, info)); 144 145 } else if (!boolean) { 145 146 i->second.termweight += wt->get_maxpart(); 147 AssertEq(stats->get_termfreq(query->tname), i->second.termfreq); 148 DEBUGLINE(MATCH, "Increasing term_info[" << query->tname << "] to (" << i->second.termfreq << ", " << i->second.termweight << ")"); 146 149 } 147 150 148 151 LeafPostList * pl = db->open_post_list(query->tname); -
xapian-core/docs/remote_protocol.html
164 164 <li> <code>MSG_QUERY L<serialised Xapian::Query object> 165 165 I<query length> I<collapse key number> <docid order> 166 166 I<sort key number> <sort by> B<sort value forward> 167 <percent cutoff> F<weight cutoff> <serialised Xapian::Weight object> <serialised Xapian::RSet object></code>167 <percent cutoff> F<weight cutoff> B<need_percentages> <serialised Xapian::Weight object> <serialised Xapian::RSet object></code> 168 168 <li> <code>REPLY_STATS <serialised Stats object></code> 169 169 <li> <code>MSG_GETMSET I<first> I<max items> I<check at least> 170 170 <serialised global Stats object></code> -
xapian-core/tests/api_anydb.cc
473 473 DEFINE_TESTCASE(topercent1, backend) { 474 474 Xapian::Enquire enquire(get_database("apitest_simpledata")); 475 475 enquire.set_query(query("this")); 476 enquire.set_calculate_percentages(true); 476 477 Xapian::MSet mymset = enquire.get_mset(0, 20); 477 478 478 479 int last_pct = 100; … … 491 492 return true; 492 493 } 493 494 495 // tests that the percent functions error if percents weren't calculated 496 DEFINE_TESTCASE(topercent2, backend) { 497 Xapian::Enquire enquire(get_database("apitest_simpledata")); 498 enquire.set_query(query("this")); 499 Xapian::MSet mymset = enquire.get_mset(0, 20); 500 501 for (Xapian::MSetIterator i = mymset.begin(); i != mymset.end(); ++i) { 502 TEST_EXCEPTION(Xapian::InvalidOperationError, 503 mymset.convert_to_percent(i)); 504 TEST_EXCEPTION(Xapian::InvalidOperationError, 505 i.get_percent()); 506 TEST_EXCEPTION(Xapian::InvalidOperationError, 507 mymset.convert_to_percent(i.get_weight())); 508 } 509 return true; 510 } 511 494 512 class myExpandFunctor : public Xapian::ExpandDecider { 495 513 public: 496 514 bool operator()(const string & tname) const { … … 568 586 569 587 // tests the percent cutoff option 570 588 DEFINE_TESTCASE(pctcutoff1, backend) { 571 Xapian::Enquire enquire(get_database("apitest_simpledata")); 589 Xapian::Database db(get_database("apitest_simpledata")); 590 Xapian::Enquire enquire(db); 572 591 enquire.set_query(query(Xapian::Query::OP_OR, 573 592 "this", "line", "paragraph", "rubbish")); 593 enquire.set_calculate_percentages(true); 574 594 Xapian::MSet mymset1 = enquire.get_mset(0, 100); 575 595 576 596 if (verbose) { … … 599 619 tout << "Cutoff percent: " << my_pct << "\n"; 600 620 } 601 621 622 enquire = Xapian::Enquire(db); 623 enquire.set_query(query(Xapian::Query::OP_OR, 624 "this", "line", "paragraph", "rubbish")); 602 625 enquire.set_cutoff(my_pct); 603 626 Xapian::MSet mymset2 = enquire.get_mset(0, 100); 604 627 -
xapian-core/include/xapian/enquire.h
4 4 /* Copyright 1999,2000,2001 BrightStation PLC 5 5 * Copyright 2001,2002 Ananova Ltd 6 6 * Copyright 2002,2003,2004,2005,2006,2007,2008 Olly Betts 7 * Copyright 2008 Lemur Consulting Ltd 7 8 * 8 9 * This program is free software; you can redistribute it and/or 9 10 * modify it under the terms of the GNU General Public License as … … 92 93 void fetch() const; 93 94 94 95 /** This converts the weight supplied to a percentage score. 96 * 95 97 * The return value will be in the range 0 to 100, and will be 0 if 96 98 * and only if the item did not match the query at all. 99 * 100 * Percentage weight calculation must have been enabled during the 101 * match. See @a Enquire::set_calculate_percentages() for more 102 * details. 103 * 104 * @exception InvalidOperationError if percentage weights were not 105 * calculated during the match. 97 106 */ 98 107 Xapian::percent convert_to_percent(Xapian::weight wt) const; 99 108 100 /// Return the percentage score for a particular item. 109 /** Return the percentage score for a particular item. 110 * 111 * The return value will be in the range 0 to 100, and will be 0 if 112 * and only if the item did not match the query at all. 113 * 114 * Percentage weight calculation must have been enabled during the 115 * match. See @a Enquire::set_calculate_percentages() for more 116 * details. 117 * 118 * @exception InvalidOperationError if percentage weights were not 119 * calculated during the match. 120 */ 101 121 Xapian::percent convert_to_percent(const MSetIterator &it) const; 102 122 103 123 /** Return the term frequency of the given query term. … … 353 373 354 374 /** This returns the weight of the document as a percentage score. 355 375 * 356 * The return value will be in the range 0 to 100: 0 meaning 357 * that the item did not match the query at all. 376 * The return value will be in the range 0 to 100, and will be 0 if 377 * and only if the item did not match the query at all. 378 * 379 * Percentage weight calculation must have been enabled during the 380 * match. See @a Enquire::set_calculate_percentages() for more 381 * details. 382 * 383 * @exception InvalidOperationError if percentage weights were not 384 * calculated during the match. 358 385 */ 359 386 Xapian::percent get_percent() const; 360 387 … … 731 758 732 759 /** Set the percentage and/or weight cutoffs. 733 760 * 761 * If a percentage cutoff is specified using this method (ie, the @a 762 * percent_cutoff parameter is non zero), percentage weights will be 763 * calculated regardless of whether set_calculate_percentages() has 764 * been called. 765 * 734 766 * @param percent_cutoff Minimum percentage score for returned 735 767 * documents. If a document has a lower percentage score than this, 736 768 * it will not appear in the MSet. If your intention is to return … … 749 781 */ 750 782 void set_cutoff(Xapian::percent percent_cutoff, Xapian::weight weight_cutoff = 0); 751 783 784 /** Set whether percentages should be calculated. 785 * 786 * Calculation of percentages involves a (hopefully small) overhead, 787 * and percentage values are often not desired. Therefore, for 788 * performance reasons, percentages are not calculated unless 789 * explicitly requested. 790 * 791 * @param val true if percentages should be calculated, false if they 792 * should not. 793 */ 794 void set_calculate_percentages(bool val); 795 752 796 /** Set the sorting to be by relevance only. 753 797 * 754 798 * This is the default. -
xapian-core/net/serialise.cc
2 2 * @brief functions to convert Xapian objects to strings and back 3 3 */ 4 4 /* Copyright (C) 2006,2007,2008 Olly Betts 5 * Copyright (C) 2008 Lemur Consulting Ltd 5 6 * 6 7 * This program is free software; you can redistribute it and/or modify 7 8 * it under the terms of the GNU General Public License as published by … … 188 189 result += serialise_double(mset.get_max_attained()); 189 190 190 191 result += serialise_double(mset.internal->percent_factor); 192 result += encode_length(int(mset.internal->have_percentages)); 191 193 192 194 result += encode_length(mset.size()); 193 195 for (Xapian::MSetIterator i = mset.begin(); i != mset.end(); ++i) { … … 226 228 Xapian::weight max_attained = unserialise_double(&p, p_end); 227 229 228 230 double percent_factor = unserialise_double(&p, p_end); 231 bool have_percentages = decode_length(&p, p_end, false); 229 232 230 233 vector<Xapian::Internal::MSetItem> items; 231 234 size_t msize = decode_length(&p, p_end, false); … … 256 259 matches_lower_bound, 257 260 matches_estimated, 258 261 max_possible, max_attained, 259 items, terminfo, percent_factor)); 262 items, terminfo, percent_factor, 263 have_percentages)); 260 264 } 261 265 262 266 string -
xapian-core/net/remoteserver.cc
2 2 * @brief Xapian remote backend server base class 3 3 */ 4 4 /* Copyright (C) 2006,2007,2008 Olly Betts 5 * Copyright (C) 2006,2007 Lemur Consulting Ltd5 * Copyright (C) 2006,2007,2008 Lemur Consulting Ltd 6 6 * 7 7 * This program is free software; you can redistribute it and/or modify 8 8 * it under the terms of the GNU General Public License as published by … … 392 392 throw Xapian::NetworkError("bad message (weight_cutoff)"); 393 393 } 394 394 395 if (*p < '0' || *p > '1') { 396 throw Xapian::NetworkError("bad message (need_percentages)"); 397 } 398 bool need_percentages(*p++ != '0'); 399 395 400 // Unserialise the Weight object. 396 401 len = decode_length(&p, p_end, true); 397 402 map<string, Xapian::Weight *>::const_iterator i; … … 410 415 411 416 Stats local_stats; 412 417 MultiMatch match(*db, query.get(), qlen, &rset, collapse_key, 413 percent_cutoff, weight_cutoff, order,418 percent_cutoff, weight_cutoff, need_percentages, order, 414 419 sort_key, sort_by, sort_value_forward, NULL, 415 420 NULL, local_stats, wt.get()); 416 421 -
xapian-core/common/omenquireinternal.h
3 3 * Copyright 1999,2000,2001 BrightStation PLC 4 4 * Copyright 2001,2002 Ananova Ltd 5 5 * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts 6 * Copyright 2008 Lemur Consulting Ltd 6 7 * 7 8 * This program is free software; you can redistribute it and/or 8 9 * modify it under the terms of the GNU General Public License as … … 161 162 162 163 Xapian::weight weight_cutoff; 163 164 165 bool calculate_percentages; 166 164 167 Xapian::valueno sort_key; 165 168 sort_setting sort_by; 166 169 bool sort_value_forward; … … 209 212 /// Factor to multiply weights by to convert them to percentages. 210 213 double percent_factor; 211 214 215 /// True iff percentage information is available. 216 bool have_percentages; 217 212 218 private: 213 219 /** The set of documents which have been requested but not yet 214 220 * collected. … … 281 287 Xapian::weight max_attained_, 282 288 const vector<Xapian::Internal::MSetItem> &items_, 283 289 const map<string, TermFreqAndWeight> &termfreqandwts_, 284 Xapian::weight percent_factor_) 290 Xapian::weight percent_factor_, 291 bool have_percentages_) 285 292 : percent_factor(percent_factor_), 293 have_percentages(have_percentages_), 286 294 termfreqandwts(termfreqandwts_), 287 295 items(items_), 288 296 firstitem(firstitem_), -
xapian-core/common/multimatch.h
2 2 * 3 3 * Copyright 1999,2000,2001 BrightStation PLC 4 4 * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts 5 * Copyright 2008 Lemur Consulting Ltd 5 6 * 6 7 * This program is free software; you can redistribute it and/or 7 8 * modify it under the terms of the GNU General Public License as … … 47 48 48 49 Xapian::weight weight_cutoff; 49 50 51 bool need_percentages; 52 50 53 Xapian::Enquire::docid_order order; 51 54 52 55 Xapian::valueno sort_key; … … 107 110 Xapian::valueno collapse_key_, 108 111 int percent_cutoff_, 109 112 Xapian::weight weight_cutoff_, 113 bool need_percentages_, 110 114 Xapian::Enquire::docid_order order_, 111 115 Xapian::valueno sort_key_, 112 116 Xapian::Enquire::Internal::sort_setting sort_by_, -
xapian-core/common/remote-database.h
2 2 * @brief RemoteDatabase is the baseclass for remote database implementations. 3 3 */ 4 4 /* Copyright (C) 2006,2007 Olly Betts 5 * Copyright (C) 2007 Lemur Consulting Ltd5 * Copyright (C) 2007,2008 Lemur Consulting Ltd 6 6 * 7 7 * This program is free software; you can redistribute it and/or 8 8 * modify it under the terms of the GNU General Public License as … … 131 131 Xapian::Enquire::Internal::sort_setting sort_by, 132 132 bool sort_value_forward, 133 133 int percent_cutoff, Xapian::weight weight_cutoff, 134 bool need_percentages, 134 135 const Xapian::Weight *wtscheme, 135 136 const Xapian::RSet &omrset); 136 137 -
xapian-core/api/omenquire.cc
3 3 * Copyright 1999,2000,2001 BrightStation PLC 4 4 * Copyright 2001,2002 Ananova Ltd 5 5 * Copyright 2002,2003,2004,2005,2006,2007,2008 Olly Betts 6 * Copyright 2007 Lemur Consulting Ltd6 * Copyright 2007,2008 Lemur Consulting Ltd 7 7 * 8 8 * This program is free software; you can redistribute it and/or 9 9 * modify it under the terms of the GNU General Public License as … … 344 344 MSet::Internal::convert_to_percent_internal(Xapian::weight wt) const 345 345 { 346 346 DEBUGAPICALL(Xapian::percent, "Xapian::MSet::Internal::convert_to_percent", wt); 347 if (!have_percentages) 348 throw Xapian::InvalidOperationError("Percentage weights were not calculated during match"); 347 349 if (percent_factor == 0) RETURN(100); 348 350 349 351 // FIXME: + 0.5 ??? … … 612 614 Enquire::Internal::Internal(const Database &db_, ErrorHandler * errorhandler_) 613 615 : db(db_), query(), collapse_key(Xapian::BAD_VALUENO), 614 616 order(Enquire::ASCENDING), percent_cutoff(0), weight_cutoff(0), 617 calculate_percentages(false), 615 618 sort_key(Xapian::BAD_VALUENO), sort_by(REL), sort_value_forward(true), 616 619 sorter(0), errorhandler(errorhandler_), weight(0) 617 620 { … … 653 656 weight = new BM25Weight; 654 657 } 655 658 659 bool need_percentages = calculate_percentages || (percent_cutoff != 0); 656 660 Stats stats; 657 661 ::MultiMatch match(db, query.internal.get(), qlen, rset, collapse_key, 658 percent_cutoff, weight_cutoff, 662 percent_cutoff, weight_cutoff, need_percentages, 659 663 order, sort_key, sort_by, sort_value_forward, sorter, 660 664 errorhandler, stats, weight); 661 665 // Run query and put results into supplied Xapian::MSet object. … … 907 911 } 908 912 909 913 void 914 Enquire::set_calculate_percentages(bool val) 915 { 916 internal->calculate_percentages = val; 917 } 918 919 void 910 920 Enquire::set_sort_by_relevance() 911 921 { 912 922 internal->sort_by = Internal::REL; -
xapian-core/backends/remote/remote-database.cc
2 2 * @brief Remote backend database class 3 3 */ 4 4 /* Copyright (C) 2006,2007,2008 Olly Betts 5 * Copyright (C) 2007 Lemur Consulting Ltd5 * Copyright (C) 2007,2008 Lemur Consulting Ltd 6 6 * 7 7 * This program is free software; you can redistribute it and/or 8 8 * modify it under the terms of the GNU General Public License as … … 440 440 Xapian::Enquire::Internal::sort_setting sort_by, 441 441 bool sort_value_forward, 442 442 int percent_cutoff, Xapian::weight weight_cutoff, 443 bool need_percentages, 443 444 const Xapian::Weight *wtscheme, 444 445 const Xapian::RSet &omrset) 445 446 { … … 456 457 message += char('0' + sort_value_forward); 457 458 message += char(percent_cutoff); 458 459 message += serialise_double(weight_cutoff); 460 message += char('0' + need_percentages); 459 461 460 462 tmp = wtscheme->name(); 461 463 message += encode_length(tmp.size()); -
xapian-bindings/xapian.i
375 375 void set_docid_order(docid_order order); 376 376 377 377 void set_cutoff(int percent_cutoff, weight weight_cutoff = 0); 378 void set_calculate_percentages(bool val); 378 379 379 380 void set_sort_by_relevance(); 380 381 void set_sort_by_value(Xapian::valueno sort_key, bool ascending = true);