39 const Query Query::MatchAll((
string()));
41 const Query Query::MatchNothing;
59 if (!subquery.
empty())
71 if (!subquery.
internal.get())
return;
72 switch (subquery.
internal->get_type()) {
103 const std::string & begin,
const std::string & end)
112 }
else if (
usual(begin <= end)) {
118 const std::string & pattern,
123 LOGCALL_CTOR(API,
"Query", op_ | pattern | max_expansion | max_type | combiner);
140 vector<pair<Xapian::termpos, string>> terms;
141 internal->gather_terms(static_cast<void*>(&terms));
142 sort(terms.begin(), terms.end());
145 const string * old_term = NULL;
147 for (
auto && i : terms) {
149 if (old_term && old_pos == i.first && *old_term == i.second)
152 v.push_back(i.second);
154 old_term = &(i.second);
165 vector<pair<Xapian::termpos, string>> terms;
166 internal->gather_terms(static_cast<void*>(&terms));
167 sort(terms.begin(), terms.end(), [](
168 const pair<Xapian::termpos, string>& a,
169 const pair<Xapian::termpos, string>& b) {
170 return a.second < b.second;
174 const string * old_term = NULL;
175 for (
auto && i : terms) {
177 if (old_term && *old_term == i.second)
180 v.push_back(i.second);
181 old_term = &(i.second);
189 return (
internal.
get() ?
internal->get_length() : 0);
197 internal->serialise(result);
204 const char * p = s.data();
205 const char * end = p + s.size();
216 return internal->get_type();
222 return internal.get() ?
internal->get_num_subqueries() : 0;
234 string desc =
"Query(";
236 desc +=
internal->get_description();
247 "OP_PHRASE or OP_ELITE_SET");
333 internal = branch_query->
done();
Xapian::termcount get_length() const
Return the length of this query object.
The Xapian namespace contains public interfaces for the Xapian library.
static const Query unserialise(const std::string &serialised, const Registry ®=Registry())
Unserialise a string and return a Query object.
const Query get_subquery(size_t n) const
Read a top level subquery.
Match documents which an odd number of subqueries match.
void init(Query::op op_, size_t n_subqueries, Xapian::termcount window=0)
const TermIterator get_terms_begin() const
Begin iterator for terms in the query object.
Pick the maximum weight of any subquery.
Xapian::Internal::intrusive_ptr< Internal > internal
A vector-like container of terms which can be iterated.
const TermIterator get_unique_terms_begin() const
Begin iterator for unique terms in the query object.
Hierarchy of classes which Xapian can throw as exceptions.
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Pick the best N subqueries and combine with OP_OR.
Value returned by get_type() for MatchAll or equivalent.
Scale the weight contributed by a subquery.
Match only documents where all subqueries match near and in order.
Match the first subquery taking extra weight from other subqueries.
Value returned by get_type() for a PostingSource.
Registry for user subclasses.
Match like OP_AND but only taking weight from the first subquery.
Query()
Construct a query matching no documents.
Match only documents where a value slot is >= a given value.
Match only documents where a value slot is within a given range.
Match only documents where a value slot is <= a given value.
std::string serialise() const
Serialise this object into a string.
Construct an invalid query.
Base class which provides an "external" source of postings.
#define LOGCALL_CTOR(CATEGORY, CLASS, PARAMS)
Match like OP_OR but weighting as if a single term.
This class stores a list of terms.
Match only documents which all subqueries match.
virtual Query::Internal * done()=0
void add_subquery(bool positional, const Xapian::Query &subquery)
size_t get_num_subqueries() const
Get the number of subqueries of the top level query.
std::string get_description() const
Return a string describing this object.
Match only documents where all subqueries match near each other.
static Query::Internal * unserialise(const char **p, const char *end, const Registry ®)
Value returned by get_type() for a term.
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
Match documents which the first subquery matches but no others do.
Match documents which at least one subquery matches.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
static const Xapian::Query MatchNothing
A query matching no documents.
op get_type() const
Get the type of the top level of the query.
Various assertion macros.
Class representing a query.
virtual void add_subquery(const Xapian::Query &subquery)=0
UnimplementedError indicates an attempt to use an unimplemented feature.
Value returned by get_type() for MatchNothing or equivalent.