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;
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;
778 virtual void serialise(std::string & result)
const = 0;
782 virtual Query::op XAPIAN_NOTHROW(get_type()
const) XAPIAN_PURE_FUNCTION = 0;
784 virtual const Query get_subquery(
size_t n)
const;
786 virtual std::string get_description()
const = 0;
789 virtual void gather_terms(
void * void_terms)
const;
798 }
else if (
this != &o &&
800 internal->_refs == 1 &&
801 get_type() == OP_AND) {
803 add_subquery(
false, o);
805 *
this =
Query(OP_AND, *
this, o);
815 }
else if (
this != &o &&
817 internal->_refs == 1 &&
818 get_type() == OP_OR) {
820 add_subquery(
false, o);
822 *
this =
Query(OP_OR, *
this, o);
832 }
else if (
internal.
get() == o.
internal.get()) {
835 }
else if (
internal.
get() &&
836 internal->_refs == 1 &&
837 get_type() == OP_XOR) {
839 add_subquery(
false, o);
841 *
this =
Query(OP_XOR, *
this, o);
848 #endif // XAPIAN_INCLUDED_QUERY_H const TermIterator get_unique_terms_end() const
End iterator for unique terms in the query object.
The Xapian namespace contains public interfaces for the Xapian library.
Query(const Query &o)
Copying is allowed.
Query & operator=(const Query &o)
Copying is allowed.
Abstract base class for postlists.
#define XAPIAN_PURE_FUNCTION
Like XAPIAN_CONST_FUNCTION, but such a function can also examine global memory, perhaps via pointer o...
static const Xapian::Query MatchAll
A query matching all documents.
Match documents which an odd number of subqueries match.
void init(Query::op op_, Xapian::termcount window, const I &, const I &, std::input_iterator_tag)
Compiler attribute macros.
void add_subquery(bool, const std::string &subquery)
Query(op op_, I begin, I end, Xapian::termcount window=0)
Construct a Query object from a begin/end iterator pair.
Xapian::Internal::intrusive_ptr< Internal > internal
const Query operator^=(const Query &o)
Combine with another Xapian::Query object using OP_XOR.
Query(Query::op op_)
Construct with just an operator.
#define XAPIAN_VISIBILITY_DEFAULT
const Query operator &=(const Query &o)
Combine with another Xapian::Query object using OP_AND.
Class for iterating over a list of terms.
const Query operator|(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_OR.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Value returned by get_type() for MatchAll or equivalent.
Value returned by get_type() for a PostingSource.
Define XAPIAN_VISIBILITY_* macros.
Registry for user subclasses.
Query()
Construct a query matching no documents.
const Query operator/(const Query &q, double factor)
Inverse-scale a Xapian::Query object using OP_SCALE_WEIGHT.
Query(op op_, const Xapian::Query &a, const Xapian::Query &b)
Construct a Query object by combining two others.
Throw an error if OP_WILDCARD exceeds its expansion limit.
const Query operator/=(double factor)
Inverse scale using OP_SCALE_WEIGHT.
Construct an invalid query.
Base class which provides an "external" source of postings.
void add_subquery(bool positional, const Xapian::Query *subquery)
Base class for objects managed by intrusive_ptr.
const Query operator &(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_AND.
const Query operator|=(const Query &o)
Combine with another Xapian::Query object using OP_OR.
Match only documents which all subqueries match.
InvertedQuery_(const Query &query_)
void init(Query::op op_, Xapian::termcount window, const I &begin, const I &end, std::random_access_iterator_tag)
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
const Query operator*=(double factor)
Scale using OP_SCALE_WEIGHT.
Query(op op_, const std::string &a, const std::string &b)
Construct a Query object by combining two terms.
const Query operator &=(Query &a, const InvertedQuery_ &b)
Combine two Xapian::Query objects using OP_AND_NOT with result in the first.
InvertedQuery_(const InvertedQuery_ &o)
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.
Stop expanding when OP_WILDCARD reaches its expansion limit.
Class for iterating over a list of document ids.
const Query operator^(const Query &a, const Query &b)
Combine two Xapian::Query objects using OP_XOR.
Class representing a query.
A smart pointer that uses intrusive reference counting.
const TermIterator get_terms_end() const
End iterator for terms in the query object.
Class for iterating over a list of terms.
Query(Internal *internal_)
Class for looking up user subclasses during unserialisation.