diff --git a/xapian-core/api/queryinternal.cc b/xapian-core/api/queryinternal.cc
index b5d44ff..20f9a2e 100644
a
|
b
|
class OrContext : public Context {
|
166 | 166 | /// Select the best set_size postlists from the last out_of added. |
167 | 167 | void select_elite_set(size_t set_size, size_t out_of); |
168 | 168 | |
| 169 | /// Select the set_size postlists with the highest term frequency. |
| 170 | void select_most_frequent(size_t set_size); |
| 171 | |
169 | 172 | PostList * postlist(QueryOptimiser* qopt); |
170 | 173 | PostList * postlist_max(QueryOptimiser* qopt); |
171 | 174 | }; |
… |
… |
OrContext::select_elite_set(size_t set_size, size_t out_of)
|
183 | 186 | pls.resize(pls.size() - out_of + set_size); |
184 | 187 | } |
185 | 188 | |
| 189 | void |
| 190 | OrContext::select_most_frequent(size_t set_size) |
| 191 | { |
| 192 | vector<PostList*>::iterator begin = pls.begin(); |
| 193 | nth_element(begin, begin + set_size - 1, pls.end(), |
| 194 | ComparePostListTermFreqAscending()); |
| 195 | for_each(begin + set_size, pls.end(), delete_ptr<PostList>()); |
| 196 | pls.resize(set_size); |
| 197 | } |
| 198 | |
186 | 199 | PostList * |
187 | 200 | OrContext::postlist(QueryOptimiser* qopt) |
188 | 201 | { |
… |
… |
QueryWildcard::postlist(QueryOptimiser * qopt, double factor) const
|
854 | 867 | } |
855 | 868 | OrContext ctx(0); |
856 | 869 | AutoPtr<TermList> t(qopt->db.open_allterms(pattern)); |
| 870 | #if 0 |
857 | 871 | Xapian::termcount expansions_left = max_expansion; |
858 | 872 | // If there's no expansion limit, set expansions_left to the maximum |
859 | 873 | // value Xapian::termcount can hold. |
860 | 874 | if (expansions_left == 0) |
861 | 875 | --expansions_left; |
| 876 | #endif |
862 | 877 | while (true) { |
863 | 878 | t->next(); |
864 | 879 | if (t->at_end()) |
865 | 880 | break; |
| 881 | #if 0 |
866 | 882 | if (expansions_left-- == 0) { |
867 | 883 | string msg("Wildcard "); |
868 | 884 | msg += pattern; |
… |
… |
QueryWildcard::postlist(QueryOptimiser * qopt, double factor) const
|
871 | 887 | msg += " terms"; |
872 | 888 | throw Xapian::WildcardError(msg); |
873 | 889 | } |
| 890 | #endif |
874 | 891 | const string & term = t->get_termname(); |
875 | 892 | ctx.add_postlist(qopt->open_lazy_post_list(term, 1, or_factor)); |
876 | 893 | } |
877 | 894 | |
| 895 | if (max_expansion && ctx.size() > max_expansion) |
| 896 | ctx.select_most_frequent(max_expansion); |
| 897 | |
878 | 898 | if (factor != 0.0) { |
879 | 899 | if (op != Query::OP_SYNONYM) { |
880 | 900 | qopt->set_total_subqs(qopt->get_total_subqs() + ctx.size()); |