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.
51 template<
bool,
typename T =
void>
struct EnableIf { };
317 WILDCARD_LIMIT_MOST_FREQUENT
346 #ifdef XAPIAN_MOVE_SEMANTICS
363 Query(
const std::string & term,
397 bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE);
398 add_subquery(positional, a);
399 add_subquery(positional, b);
409 Query(
op op_,
const std::string & a,
const std::string & b)
412 add_subquery(
false, a);
413 add_subquery(
false, b);
433 const std::string & range_lower,
const std::string & range_upper);
456 const std::string & pattern,
458 int max_type = WILDCARD_LIMIT_ERROR,
459 op combiner = OP_SYNONYM);
477 typename T =
typename std::iterator_traits<I>,
478 typename V =
typename T::value_type,
480 typename iterator_category =
typename T::iterator_category>
484 init(op_, window, begin, end, iterator_category());
485 bool positional = (op_ == OP_NEAR || op_ == OP_PHRASE);
486 for (I i = begin; i != end; ++i) {
487 add_subquery(positional, *i);
496 Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qend,
500 Query(op op_, XapianSWIGStrItor qbegin, XapianSWIGStrItor qend,
537 bool XAPIAN_NOTHROW(empty() const) {
538 return internal.get() == 0;
542 std::string serialise()
const;
551 static const Query unserialise(
const std::string & serialised,
565 const
Query get_subquery(
size_t n) const;
568 std::
string get_description() const;
601 const
Query operator*=(
double factor) {
602 return (*
this =
Query(factor, *
this));
610 return (*
this =
Query(1.0 / factor, *
this));
630 const I & begin,
const I & end, std::random_access_iterator_tag)
632 init(op_, end - begin, window);
637 const I &,
const I &, std::input_iterator_tag)
639 init(op_, 0, window);
642 void add_subquery(
bool positional,
const Xapian::Query & subquery);
650 add_subquery(positional, *subquery);
685 return Query(factor, q);
696 return Query(factor, q);
707 return Query(1.0 / factor, q);
756 operator~(
const Query &q)
779 double factor)
const;
783 double factor)
const;
787 double factor)
const;
791 virtual
void serialise(std::
string & result) const = 0;
797 virtual const
Query get_subquery(
size_t n) const;
799 virtual std::
string get_description() const = 0;
802 virtual
void gather_terms(
void * void_terms) const;
811 }
else if (
this != &o &&
813 internal->_refs == 1 &&
814 get_type() == OP_AND) {
816 add_subquery(
false, o);
818 *
this =
Query(OP_AND, *
this, o);
828 }
else if (
this != &o &&
845 }
else if (
internal.get() == o.
internal.get()) {
848 }
else if (
internal.get() &&
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
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_ &)
InvertedQuery_(const InvertedQuery_ &o)
InvertedQuery_(const Query &query_)
Abstract base class for postlists.
Base class which provides an "external" source of postings.
virtual PostingIterator::Internal * postlist(QueryOptimiser *qopt, double factor) 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.
Query(op op_, I begin, I end, Xapian::termcount window=0)
Construct a Query object from a begin/end iterator pair.
@ 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.
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)
op get_type() const
Get the type of the top level of the query.
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