22 #ifndef XAPIAN_INCLUDED_QUERY_H
23 #define XAPIAN_INCLUDED_QUERY_H
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/query.h> directly; include <xapian.h> instead.
307 WILDCARD_LIMIT_MOST_FREQUENT
336 #ifdef XAPIAN_MOVE_SEMANTICS
353 Query(
const std::string & term,
387 bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE);
388 add_subquery(positional, a);
389 add_subquery(positional, b);
399 Query(
op op_,
const std::string & a,
const std::string & b)
402 add_subquery(
false, a);
403 add_subquery(
false, b);
423 const std::string & range_lower,
const std::string & range_upper);
446 const std::string & pattern,
448 int max_type = WILDCARD_LIMIT_ERROR,
449 op combiner = OP_SYNONYM);
470 typedef typename std::iterator_traits<I>::iterator_category iterator_category;
471 init(op_, window, begin, end, iterator_category());
472 bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE);
473 for (I i = begin; i != end; ++i) {
474 add_subquery(positional, *i);
483 Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qend,
487 Query(op op_, XapianSWIGStrItor qbegin, XapianSWIGStrItor qend,
524 bool XAPIAN_NOTHROW(empty() const) {
525 return internal.get() == 0;
529 std::string serialise()
const;
538 static const Query unserialise(
const std::string & serialised,
552 const
Query get_subquery(
size_t n) const;
555 std::
string get_description() const;
588 const
Query operator*=(
double factor) {
589 return (*
this =
Query(factor, *
this));
597 return (*
this =
Query(1.0 / factor, *
this));
617 const I & begin,
const I & end, std::random_access_iterator_tag)
619 init(op_, end - begin, window);
624 const I &,
const I &, std::input_iterator_tag)
626 init(op_, 0, window);
629 void add_subquery(
bool positional,
const Xapian::Query & subquery);
637 add_subquery(positional, *subquery);
672 return Query(factor, q);
683 return Query(factor, q);
694 return Query(1.0 / factor, q);
743 operator~(
const Query &q)
766 double factor)
const;
770 double factor)
const;
774 double factor)
const;
798 }
else if (
this != &o &&
815 }
else if (
this != &o &&
832 }
else if (
internal.get() == o.
internal.get()) {
835 }
else if (
internal.get() &&
Compiler attribute macros.
#define XAPIAN_PURE_FUNCTION
Like XAPIAN_CONST_FUNCTION, but such a function can also examine global memory, perhaps via pointer o...
Base class for objects managed by intrusive_ptr.
A smart pointer that uses intrusive reference counting.
friend const InvertedQuery_ operator~(const Query &q)
void operator=(const InvertedQuery_ &)
friend const Query operator&(const Query &a, const InvertedQuery_ &b)
Combine two Xapian::Query objects using OP_AND_NOT.
InvertedQuery_(const InvertedQuery_ &o)
InvertedQuery_(const Query &query_)
friend const Query operator&=(Query &a, const InvertedQuery_ &b)
Combine two Xapian::Query objects using OP_AND_NOT with result in the first.
Abstract base class for postlists.
Base class which provides an "external" source of postings.
virtual termcount get_length() const
virtual void postlist_sub_xor(Xapian::Internal::XorContext &ctx, QueryOptimiser *qopt, double factor) const
static Query::Internal * unserialise(const char **p, const char *end, const Registry ®)
virtual void postlist_sub_and_like(Xapian::Internal::AndContext &ctx, QueryOptimiser *qopt, double factor) const
virtual PostingIterator::Internal * postlist(QueryOptimiser *qopt, double factor) const =0
virtual void postlist_sub_or_like(Xapian::Internal::OrContext &ctx, QueryOptimiser *qopt, double factor) const
virtual const Query get_subquery(size_t n) const
virtual std::string get_description() const =0
virtual void gather_terms(void *void_terms) const
virtual Query::op get_type() const =0
virtual size_t get_num_subqueries() const
virtual void serialise(std::string &result) const =0
Class representing a query.
@ WILDCARD_LIMIT_ERROR
Throw an error if OP_WILDCARD exceeds its expansion limit.
@ WILDCARD_LIMIT_FIRST
Stop expanding when OP_WILDCARD reaches its expansion limit.
bool empty() const
Check if this query is Xapian::Query::MatchNothing.
const Query operator/=(double factor)
Inverse scale using OP_SCALE_WEIGHT.
const TermIterator get_terms_end() const
End iterator for terms in the query object.
Query(op op_, const std::string &a, const std::string &b)
Construct a Query object by combining two terms.
const Query operator^=(const Query &o)
Combine with another Xapian::Query object using OP_XOR.
const TermIterator get_unique_terms_end() const
End iterator for unique terms in the query object.
@ LEAF_POSTING_SOURCE
Value returned by get_type() for a PostingSource.
@ OP_XOR
Match documents which an odd number of subqueries match.
@ LEAF_MATCH_ALL
Value returned by get_type() for MatchAll or equivalent.
@ OP_AND
Match only documents which all subqueries match.
@ OP_OR
Match documents which at least one subquery matches.
@ OP_AND_NOT
Match documents which the first subquery matches but no others do.
@ OP_INVALID
Construct an invalid query.
void add_subquery(bool positional, const Xapian::Query &subquery)
Query()
Construct a query matching no documents.
void init(Query::op op_, Xapian::termcount window, const I &begin, const I &end, std::random_access_iterator_tag)
void add_subquery(bool, const std::string &subquery)
static const Xapian::Query MatchNothing
A query matching no documents.
const Query operator|=(const Query &o)
Combine with another Xapian::Query object using OP_OR.
Query(Internal *internal_)
Query(const Query &o)
Copying is allowed.
Query(op op_, I begin, I end, Xapian::termcount window=0)
Construct a Query object from a begin/end iterator pair.
void add_subquery(bool positional, const Xapian::Query *subquery)
Query(op op_, const Xapian::Query &a, const Xapian::Query &b)
Construct a Query object by combining two others.
Xapian::Internal::intrusive_ptr< Internal > internal
void init(Query::op op_, Xapian::termcount window, const I &, const I &, std::input_iterator_tag)
Query(Query::op op_)
Construct with just an operator.
Query & operator=(const Query &o)
Copying is allowed.
static const Xapian::Query MatchAll
A query matching all documents.
Registry for user subclasses.
Class for iterating over a list of terms.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
const Query operator^(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_XOR.
const Query operator|(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_OR.
const Query operator&(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_AND.
unsigned valueno
The number for a value slot in a document.
const Query operator&=(Query &a, const InvertedQuery_ &b)
Combine two Xapian::Query objects using OP_AND_NOT with result in the first.
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
const Query operator/(const Query &q, double factor)
Inverse-scale a Xapian::Query object using OP_SCALE_WEIGHT.
Class for iterating over a list of document ids.
Class for looking up user subclasses during unserialisation.
Class for iterating over a list of terms.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT