Ticket #110: xapian-fix-inconsistent-paging-with-sort-by-relevance-then-value.patch
File xapian-fix-inconsistent-paging-with-sort-by-relevance-then-value.patch, 3.6 KB (added by , 17 years ago) |
---|
-
matcher/multimatch.cc
2 2 * 3 3 * Copyright 1999,2000,2001 BrightStation PLC 4 4 * Copyright 2001,2002 Ananova Ltd 5 * Copyright 2002,2003,2004,2005,2006 Olly Betts5 * Copyright 2002,2003,2004,2005,2006,2007 Olly Betts 6 6 * Copyright 2003 Orange PCS Ltd 7 7 * Copyright 2003 Sam Liddicott 8 8 * … … 61 61 62 62 using namespace std; 63 63 64 const Xapian::Enquire::Internal::sort_setting REL = 65 Xapian::Enquire::Internal::REL; 66 const Xapian::Enquire::Internal::sort_setting REL_VAL = 67 Xapian::Enquire::Internal::REL_VAL; 68 const Xapian::Enquire::Internal::sort_setting VAL = 69 Xapian::Enquire::Internal::VAL; 70 const Xapian::Enquire::Internal::sort_setting VAL_REL = 71 Xapian::Enquire::Internal::VAL_REL; 72 64 73 //////////////////////////////////// 65 74 // Initialisation and cleaning up // 66 75 //////////////////////////////////// … … 139 148 rem_db->set_query(query, qlen, collapse_key, order, sort_key, 140 149 sort_by, sort_value_forward, percent_cutoff, 141 150 weight_cutoff, weight, *subrset); 151 bool decreasing_relevance = 152 (sort_by == REL || sort_by == REL_VAL); 142 153 smatch = new RemoteSubMatch(rem_db, gatherer.get(), 143 sort_key != Xapian::valueno(-1));154 !decreasing_relevance); 144 155 } else { 145 156 #endif /* XAPIAN_HAS_REMOTE_BACKEND */ 146 157 smatch = new LocalSubMatch(subdb, query, qlen, *subrset, gatherer.get(), weight); … … 417 428 418 429 DEBUGLINE(MATCH, "Candidate document id " << did << " wt " << wt); 419 430 Xapian::Internal::MSetItem new_item(wt, did); 420 if (sort_ key != Xapian::valueno(-1)) {431 if (sort_by != REL) { 421 432 const unsigned int multiplier = db.internal.size(); 422 433 Assert(multiplier != 0); 423 434 Xapian::doccount n = (new_item.did - 1) % multiplier; // which actual database … … 428 439 429 440 // Test if item has high enough weight (or sort key) to get into 430 441 // proto-mset. 431 if (sort_ key != Xapian::valueno(-1)|| min_item.wt > 0.0)442 if (sort_by != REL || min_item.wt > 0.0) 432 443 if (!mcmp(new_item, min_item)) continue; 433 444 434 445 Xapian::Internal::RefCntPtr<Xapian::Document::Internal> doc; … … 476 487 } else { 477 488 ++duplicates_found; 478 489 Xapian::Internal::MSetItem &old_item = oldkey->second.first; 479 // FIXME: what about sort_key != Xapian::valueno(-1) case 480 // here? 490 // FIXME: what about the (sort_by != REL) case here? 481 491 if (mcmp(old_item, new_item)) { 482 492 DEBUGLINE(MATCH, "collapsem: better exists: " << 483 493 new_item.collapse_key); … … 495 505 496 506 // This is best match with this key so far: 497 507 // remove the old one from the MSet 498 if ((sort_ key == Xapian::valueno(-1)&& min_item.wt <= 0.0) ||508 if ((sort_by != VAL && min_item.wt <= 0.0) || 499 509 mcmp(old_item, min_item)) { 500 510 // Old one hasn't fallen out of MSet yet 501 511 // Scan through (unsorted) MSet looking for entry … … 540 550 pop_heap<vector<Xapian::Internal::MSetItem>::iterator, 541 551 MSetCmp>(items.begin(), items.end(), mcmp); 542 552 items.pop_back(); 543 if (sort_ key != Xapian::valueno(-1)) {553 if (sort_by == REL || sort_by == REL_VAL) { 544 554 Xapian::weight tmp = min_item.wt; 545 555 min_item = items.front(); 546 556 min_item.wt = tmp; … … 554 564 } else { 555 565 items.push_back(new_item); 556 566 is_heap = false; 557 if (sort_ key == Xapian::valueno(-1)&& items.size() == max_msize) {567 if (sort_by == REL && items.size() == max_msize) { 558 568 // We're done if this is a forward boolean match 559 569 // (bodgetastic, FIXME better if we can) 560 570 if (max_weight == 0 && sort_forward) break;