diff --git a/xapian-core/api/postlist.cc b/xapian-core/api/postlist.cc
index 2684913..8c259e9 100644
a
|
b
|
PostingIterator::Internal::get_wdf() const
|
47 | 47 | } |
48 | 48 | |
49 | 49 | const string * |
| 50 | PostingIterator::Internal::get_sort_key() const |
| 51 | { |
| 52 | return NULL; |
| 53 | } |
| 54 | |
| 55 | const string * |
50 | 56 | PostingIterator::Internal::get_collapse_key() const |
51 | 57 | { |
52 | 58 | return NULL; |
diff --git a/xapian-core/api/postlist.h b/xapian-core/api/postlist.h
index f5814f3..350762d 100644
a
|
b
|
class Xapian::PostingIterator::Internal : public Xapian::Internal::intrusive_bas
|
95 | 95 | /// Return the weight contribution for the current position. |
96 | 96 | virtual double get_weight() const = 0; |
97 | 97 | |
| 98 | virtual const std::string * get_sort_key() const; |
| 99 | |
98 | 100 | /** If the collapse key is already known, return it. |
99 | 101 | * |
100 | 102 | * This is implemented by MSetPostList (and MergePostList). Other |
diff --git a/xapian-core/matcher/mergepostlist.cc b/xapian-core/matcher/mergepostlist.cc
index 8ff03ae..a6701ea 100644
a
|
b
|
MergePostList::get_weight() const
|
151 | 151 | } |
152 | 152 | |
153 | 153 | const string * |
| 154 | MergePostList::get_sort_key() const |
| 155 | { |
| 156 | LOGCALL(MATCH, const string *, "MergePostList::get_sort_key", NO_ARGS); |
| 157 | Assert(current != -1); |
| 158 | RETURN(plists[current]->get_sort_key()); |
| 159 | } |
| 160 | |
| 161 | const string * |
154 | 162 | MergePostList::get_collapse_key() const |
155 | 163 | { |
156 | 164 | LOGCALL(MATCH, const string *, "MergePostList::get_collapse_key", NO_ARGS); |
diff --git a/xapian-core/matcher/mergepostlist.h b/xapian-core/matcher/mergepostlist.h
index 2e30a2e..75755ec 100644
a
|
b
|
class MergePostList : public PostList {
|
68 | 68 | |
69 | 69 | Xapian::docid get_docid() const; |
70 | 70 | double get_weight() const; |
| 71 | const string * get_sort_key() const; |
71 | 72 | const string * get_collapse_key() const; |
72 | 73 | |
73 | 74 | double get_maxweight() const; |
diff --git a/xapian-core/matcher/msetpostlist.cc b/xapian-core/matcher/msetpostlist.cc
index a4702ee..bf5c004 100644
a
|
b
|
MSetPostList::get_weight() const
|
83 | 83 | } |
84 | 84 | |
85 | 85 | const string * |
| 86 | MSetPostList::get_sort_key() const |
| 87 | { |
| 88 | LOGCALL(MATCH, const string *, "MSetPostList::get_sort_key", NO_ARGS); |
| 89 | Assert(cursor != -1); |
| 90 | RETURN(&mset_internal->items[cursor].sort_key); |
| 91 | } |
| 92 | |
| 93 | const string * |
86 | 94 | MSetPostList::get_collapse_key() const |
87 | 95 | { |
88 | 96 | LOGCALL(MATCH, const string *, "MSetPostList::get_collapse_key", NO_ARGS); |
diff --git a/xapian-core/matcher/msetpostlist.h b/xapian-core/matcher/msetpostlist.h
index cb9bad4..35d712d 100644
a
|
b
|
class MSetPostList : public PostList {
|
68 | 68 | |
69 | 69 | double get_weight() const; |
70 | 70 | |
| 71 | const string * get_sort_key() const; |
| 72 | |
71 | 73 | const string * get_collapse_key() const; |
72 | 74 | |
73 | 75 | /// Not implemented for MSetPostList. |
diff --git a/xapian-core/matcher/multimatch.cc b/xapian-core/matcher/multimatch.cc
index ef8525e..a236f26 100644
a
|
b
|
MultiMatch::get_mset(Xapian::doccount first, Xapian::doccount maxitems,
|
639 | 639 | } |
640 | 640 | |
641 | 641 | if (sort_by != REL) { |
642 | | if (sorter) { |
| 642 | const string * ptr = pl->get_sort_key(); |
| 643 | if (ptr) { |
| 644 | new_item.sort_key = *ptr; |
| 645 | } else if (sorter) { |
643 | 646 | new_item.sort_key = (*sorter)(doc); |
644 | 647 | } else { |
645 | 648 | new_item.sort_key = vsdoc.get_value(sort_key); |
diff --git a/xapian-core/net/serialise.cc b/xapian-core/net/serialise.cc
index cdeaec3..dea8156 100644
a
|
b
|
serialise_mset(const Xapian::MSet &mset)
|
172 | 172 | result += serialise_double(mset.internal->percent_factor); |
173 | 173 | |
174 | 174 | result += encode_length(mset.size()); |
| 175 | size_t j = 0; |
175 | 176 | for (Xapian::MSetIterator i = mset.begin(); i != mset.end(); ++i) { |
176 | 177 | result += serialise_double(i.get_weight()); |
177 | 178 | result += encode_length(*i); |
| 179 | const string & sort_key = mset.internal->items[j++].sort_key; |
| 180 | result += encode_length(sort_key.size()); |
| 181 | result += sort_key; |
| 182 | result += i.get_collapse_key(); |
178 | 183 | result += encode_length(i.get_collapse_key().size()); |
179 | 184 | result += i.get_collapse_key(); |
180 | 185 | result += encode_length(i.get_collapse_count()); |
… |
… |
unserialise_mset(const char * p, const char * p_end)
|
207 | 212 | double wt = unserialise_double(&p, p_end); |
208 | 213 | Xapian::docid did = decode_length(&p, p_end, false); |
209 | 214 | size_t len = decode_length(&p, p_end, true); |
| 215 | string sort_key(p, len); |
| 216 | p += len; |
| 217 | len = decode_length(&p, p_end, true); |
210 | 218 | string key(p, len); |
211 | 219 | p += len; |
212 | 220 | Xapian::doccount collapse_cnt = decode_length(&p, p_end, false); |
213 | 221 | items.push_back(Xapian::Internal::MSetItem(wt, did, key, collapse_cnt)); |
| 222 | swap(items.back().sort_key, sort_key); |
214 | 223 | } |
215 | 224 | |
216 | 225 | AutoPtr<Xapian::Weight::Internal> stats; |