4 /* Copyright (C) 2017 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_MATCHER_H
22 #define XAPIAN_INCLUDED_MATCHER_H
24 #include "api/enquireinternal.h"
25 #include "localsubmatch.h"
26 #include "remotesubmatch.h"
27 #include "weight/weightinternal.h"
29 #include "xapian/database.h"
30 #include "xapian/query.h"
43 typedef Xapian::Internal::opt_intrusive_ptr
<Xapian::MatchSpy
> opt_ptr_spy
;
49 std::vector
<std::unique_ptr
<LocalSubMatch
>> locals
;
51 std::vector
<std::unique_ptr
<RemoteSubMatch
>> remotes
;
53 Matcher(const Matcher
&) = delete;
55 Matcher
& operator=(const Matcher
&) = delete;
57 Xapian::MSet
get_local_mset(Xapian::doccount first
,
58 Xapian::doccount maxitems
,
59 Xapian::doccount check_at_least
,
60 const Xapian::MatchDecider
* mdecider
,
61 const Xapian::KeyMaker
* sorter
,
62 Xapian::valueno collapse_key
,
63 Xapian::doccount collapse_max
,
64 int percent_threshold
,
65 double percent_threshold_factor
,
66 double weight_threshold
,
67 Xapian::Enquire::docid_order order
,
68 Xapian::valueno sort_key
,
69 Xapian::Enquire::Internal::sort_setting sort_by
,
70 bool sort_val_reverse
,
72 const std::vector
<opt_ptr_spy
>& matchspies
);
77 * @param db_ Database to search
78 * @param query Query object
79 * @param query_length Query length
80 * @param rset Relevance set (NULL for none)
81 * @param stats Object to collate stats into
82 * @param wtscheme Weight object to use as factory
83 * @param have_sorter KeyMaker in use for sort keys?
84 * @param have_mdecider MatchDecider specified?
85 * @param collapse_key value slot to collapse on (Xapian::BAD_VALUENO
86 * which means no collapsing)
87 * @param collapse_max Maximum number of documents with the same key
89 * @param percent_threshold Lower bound on percentage score
90 * @param weight_threshold Lower bound on weight
91 * @param order Xapian::docid sort order
92 * @param sort_key Value slot to sort on
93 * @param sort_by What to sort results on
94 * @param sort_val_reverse Reverse direction keys sort in?
95 * @param time_limit time in seconds after which to disable
96 * check_at_least (0.0 means don't).
97 * @param matchspies MatchSpy objects to use
99 Matcher(const Xapian::Database
& db_
,
100 const Xapian::Query
& query
,
101 Xapian::termcount query_length
,
102 const Xapian::RSet
* rset
,
103 Xapian::Weight::Internal
& stats
,
104 const Xapian::Weight
* wtscheme
,
107 Xapian::valueno collapse_key
,
108 Xapian::doccount collapse_max
,
109 int percent_threshold
,
110 double weight_threshold
,
111 Xapian::Enquire::docid_order order
,
112 Xapian::valueno sort_key
,
113 Xapian::Enquire::Internal::sort_setting sort_by
,
114 bool sort_val_reverse
,
116 const std::vector
<opt_ptr_spy
>& matchspies
);
118 /** Run the match and produce an MSet object.
120 * @param first Zero-based index of the first result to return
121 * (which supports retrieving pages of results).
122 * @param maxitems The maximum number of documents to return.
123 * @param checkatleast Check at least this many documents. By default
124 * Xapian will avoiding considering documents
125 * which it can prove can't match, which is faster
126 * but can result in a loose bounds on and a poor
127 * estimate of the total number of matches -
128 * setting checkatleast higher allows trading off
129 * speed for tighter bounds and a more accurate
131 * @param mset MSet object to full in
132 * @param stats Collated stats
133 * @param mdecider MatchDecider to use (NULL for none)
134 * @param sorter KeyMaker for sort keys (NULL for none)
135 * @param collapse_key value slot to collapse on (Xapian::BAD_VALUENO
136 * which means no collapsing)
137 * @param collapse_max Maximum number of documents with the same key
139 * @param collapse_key value slot to collapse on (Xapian::BAD_VALUENO
140 * which means no collapsing)
141 * @param collapse_max Maximum number of documents with the same key
143 * @param percent_threshold Lower bound on percentage score
144 * @param weight_threshold Lower bound on weight
145 * @param order Xapian::docid sort order
146 * @param sort_key Value slot to sort on
147 * @param sort_by What to sort results on
148 * @param sort_val_reverse Reverse direction keys sort in?
149 * @param time_limit time in seconds after which to disable
150 * check_at_least (0.0 means don't).
151 * @param matchspies MatchSpy objects to use
153 Xapian::MSet
get_mset(Xapian::doccount first
,
154 Xapian::doccount maxitems
,
155 Xapian::doccount check_at_least
,
156 Xapian::Weight::Internal
& stats
,
157 const Xapian::MatchDecider
* mdecider
,
158 const Xapian::KeyMaker
* sorter
,
159 Xapian::valueno collapse_key
,
160 Xapian::doccount collapse_max
,
161 int percent_threshold
,
162 double weight_threshold
,
163 Xapian::Enquire::docid_order order
,
164 Xapian::valueno sort_key
,
165 Xapian::Enquire::Internal::sort_setting sort_by
,
166 bool sort_val_reverse
,
168 const std::vector
<opt_ptr_spy
>& matchspies
);
170 bool full_db_has_positions() const {
171 return db
.has_positions();
175 #endif // XAPIAN_INCLUDED_MATCHER_H