#include <query.h>
Collaboration diagram for Xapian::Query:
Public Types | |
enum | op { OP_AND, OP_OR, OP_AND_NOT, OP_XOR, OP_AND_MAYBE, OP_FILTER, OP_NEAR, OP_PHRASE, OP_VALUE_RANGE, OP_SCALE_WEIGHT, OP_ELITE_SET, OP_VALUE_GE, OP_VALUE_LE, OP_SYNONYM } |
Enum of possible query operations. More... | |
typedef std::vector< Internal * > | subquery_list |
The container type for storing pointers to subqueries. | |
typedef int | op_t |
Type storing the operation. | |
Public Member Functions | |
Query (const Query ©me) | |
Query & | operator= (const Query ©me) |
Query () | |
~Query () | |
Query (const std::string &tname_, Xapian::termcount wqf_=1, Xapian::termpos pos_=0) | |
Query (Query::op op_, const Query &left, const Query &right) | |
Query (Query::op op_, const std::string &left, const std::string &right) | |
template<class Iterator> | |
Query (Query::op op_, Iterator qbegin, Iterator qend, Xapian::termcount parameter=0) | |
Query (Query::op op_, Xapian::Query q, double parameter) | |
Query (Query::op op_, Xapian::valueno valno, const std::string &begin, const std::string &end) | |
Query (Query::op op_, Xapian::valueno valno, const std::string &value) | |
Query (Xapian::PostingSource *external_source) | |
Xapian::termcount | get_length () const |
TermIterator | get_terms_begin () const |
TermIterator | get_terms_end () const |
bool | empty () const |
std::string | serialise () const |
std::string | get_description () const |
Return a string describing this object. | |
Internal (const Query::Internal ©me) | |
void | operator= (const Query::Internal ©me) |
Internal (const std::string &tname_, Xapian::termcount wqf_=1, Xapian::termpos term_pos_=0) | |
Internal (op_t op_, Xapian::termcount parameter) | |
Internal (op_t op_, Xapian::valueno valno, const std::string &begin, const std::string &end) | |
Internal (op_t op_, Xapian::valueno valno, const std::string &value) | |
Internal (Xapian::PostingSource *external_source_, bool owned) | |
Construct an external source query. | |
~Internal () | |
void | add_subquery (const Query::Internal *subq) |
void | add_subquery_nocopy (Query::Internal *subq) |
void | set_dbl_parameter (double dbl_parameter_) |
double | get_dbl_parameter () const |
Query::Internal * | end_construction () |
std::string | serialise () const |
std::string | get_description () const |
Return a string describing this object. | |
Xapian::termcount | get_parameter () const |
Xapian::termcount | get_length () const |
TermIterator | get_terms () const |
Static Public Member Functions | |
static Query | unserialise (const std::string &s) |
static Query | unserialise (const std::string &s, const SerialisationContext &context) |
static Xapian::Query::Internal * | unserialise (const std::string &s, const SerialisationContext &context) |
Static Public Attributes | |
static const Xapian::Query | MatchAll |
static const Xapian::Query | MatchNothing |
static const int | OP_LEAF = -1 |
static const int | OP_EXTERNAL_SOURCE = -2 |
Friends | |
class | ::LocalSubMatch |
class | ::MultiMatch |
class | ::QueryOptimiser |
struct | ::SortPosName |
class | Query |
Queries are represented as a tree of objects.
typedef std::vector<Internal *> Xapian::Query::subquery_list |
The container type for storing pointers to subqueries.
typedef int Xapian::Query::op_t |
Type storing the operation.
enum Xapian::Query::op |
Enum of possible query operations.
Xapian::Query::Query | ( | const Query & | copyme | ) |
Copy constructor.
Xapian::Query::Query | ( | ) |
Default constructor: makes an empty query which matches no documents.
Also useful for defining a Query object to be assigned to later.
An exception will be thrown if an attempt is made to use an undefined query when building up a composite query.
Xapian::Query::~Query | ( | ) |
Destructor.
Xapian::Query::Query | ( | const std::string & | tname_, | |
Xapian::termcount | wqf_ = 1 , |
|||
Xapian::termpos | pos_ = 0 | |||
) |
A query consisting of a single term.
A query consisting of two subqueries, opp-ed together.
Xapian::Query::Query | ( | Query::op | op_, | |
const std::string & | left, | |||
const std::string & | right | |||
) |
A query consisting of two termnames opp-ed together.
Xapian::Query::Query | ( | Query::op | op_, | |
Iterator | qbegin, | |||
Iterator | qend, | |||
Xapian::termcount | parameter = 0 | |||
) | [inline] |
Combine a number of Xapian::Query-s with the specified operator.
The Xapian::Query objects are specified with begin and end iterators.
AND, OR, NEAR and PHRASE can take any number of subqueries. Other operators take exactly two subqueries.
The iterators may be to Xapian::Query objects, pointers to Xapian::Query objects, or termnames (std::string-s).
For NEAR and PHRASE, a window size can be specified in parameter.
For ELITE_SET, the elite set size can be specified in parameter.
Xapian::Query::Query | ( | Query::op | op_, | |
Xapian::Query | q, | |||
double | parameter | |||
) |
Apply the specified operator to a single Xapian::Query object, with a double parameter.
Xapian::Query::Query | ( | Query::op | op_, | |
Xapian::valueno | valno, | |||
const std::string & | begin, | |||
const std::string & | end | |||
) |
Construct a value range query on a document value.
A value range query matches those documents which have a value stored in the slot given by valno which is in the range specified by begin and end (in lexicographical order), including the endpoints.
op_ | The operator to use for the query. Currently, must be OP_VALUE_RANGE. | |
valno | The slot number to get the value from. | |
begin | The start of the range. | |
end | The end of the range. |
Xapian::Query::Query | ( | Query::op | op_, | |
Xapian::valueno | valno, | |||
const std::string & | value | |||
) |
Construct a value comparison query on a document value.
This query matches those documents which have a value stored in the slot given by valno which compares, as specified by the operator, to value.
op_ | The operator to use for the query. Currently, must be OP_VALUE_GE or OP_VALUE_LE. | |
valno | The slot number to get the value from. | |
value | The value to compare. |
Xapian::Query::Query | ( | Xapian::PostingSource * | external_source | ) | [explicit] |
Construct an external source query.
An attempt to clone the posting source will be made immediately, so if the posting source supports clone(), the source supplied may be safely deallocated after this call. If the source does not support clone(), the caller must ensure that the posting source remains valid until the Query is deallocated.
external_source | The source to use in the query. |
Xapian::Query::~Internal | ( | ) |
Destructor.
Xapian::termcount Xapian::Query::get_length | ( | ) | const |
Get the length of the query, used by some ranking formulae. This value is calculated automatically - if you want to override it you can pass a different value to Enquire::set_query().
TermIterator Xapian::Query::get_terms_begin | ( | ) | const |
Return a Xapian::TermIterator returning all the terms in the query, in order of termpos. If multiple terms have the same term position, their order is unspecified. Duplicates (same term and termpos) will be removed.
TermIterator Xapian::Query::get_terms_end | ( | ) | const [inline] |
Return a Xapian::TermIterator to the end of the list of terms in the query.
bool Xapian::Query::empty | ( | ) | const |
Test if the query is empty (i.e. was constructed using the default ctor or with an empty iterator ctor).
std::string Xapian::Query::serialise | ( | ) | const |
Serialise query into a string.
The query representation may change between Xapian releases: even between minor versions. However, it is guaranteed not to change unless the remote database protocol has also changed between releases.
static Query Xapian::Query::unserialise | ( | const std::string & | s | ) | [static] |
Unserialise a query from a string produced by serialise().
This method will fail if the query contains any external PostingSource leaf nodes.
s | The string representing the serialised query. |
static Query Xapian::Query::unserialise | ( | const std::string & | s, | |
const SerialisationContext & | context | |||
) | [static] |
Unserialise a query from a string produced by serialise().
The supplied context will be used to attempt to unserialise any external PostingSource leaf nodes. This method will fail if the query contains any external PostingSource leaf nodes which are not registered in the context.
s | The string representing the serialised query. | |
context | A context to use when unserialising the query. |
std::string Xapian::Query::get_description | ( | ) | const |
Return a string describing this object.
Xapian::Query::Internal | ( | const Query::Internal & | copyme | ) |
Copy constructor.
void Xapian::Query::operator= | ( | const Query::Internal & | copyme | ) |
Assignment.
Xapian::Query::Internal | ( | const std::string & | tname_, | |
Xapian::termcount | wqf_ = 1 , |
|||
Xapian::termpos | term_pos_ = 0 | |||
) | [explicit] |
A query consisting of a single term.
Xapian::Query::Internal | ( | op_t | op_, | |
Xapian::termcount | parameter | |||
) |
Create internals given only the operator and a parameter.
Xapian::Query::Internal | ( | op_t | op_, | |
Xapian::valueno | valno, | |||
const std::string & | begin, | |||
const std::string & | end | |||
) |
Construct a range query on a document value.
Xapian::Query::Internal | ( | op_t | op_, | |
Xapian::valueno | valno, | |||
const std::string & | value | |||
) |
Construct a value greater-than-or-equal query on a document value.
Xapian::Query::Internal | ( | Xapian::PostingSource * | external_source_, | |
bool | owned | |||
) | [explicit] |
Construct an external source query.
void Xapian::Query::add_subquery | ( | const Query::Internal * | subq | ) |
Add a subquery.
void Xapian::Query::add_subquery_nocopy | ( | Query::Internal * | subq | ) |
Add a subquery without copying it.
subq is owned by the object this is called on after the call.
Query::Internal* Xapian::Query::end_construction | ( | ) |
Finish off the construction.
std::string Xapian::Query::serialise | ( | ) | const [inline] |
Return a string in an easily parsed form which contains all the information in a query.
std::string Xapian::Query::get_description | ( | ) | const |
Return a string describing this object.
Xapian::termcount Xapian::Query::get_parameter | ( | ) | const [inline] |
Get the numeric parameter used in this query.
This is used by the QueryParser to get the value number for VALUE_RANGE queries. It should be replaced by a public method on the Query class at some point, but the API which should be used for that is unclear, so this is a temporary workaround.
Xapian::termcount Xapian::Query::get_length | ( | ) | const |
Get the length of the query, used by some ranking formulae. This value is calculated automatically - if you want to override it you can pass a different value to Enquire::set_query().
TermIterator Xapian::Query::get_terms | ( | ) | const |
Return an iterator over all the terms in the query, in order of termpos. If multiple terms have the same term position, their order is unspecified. Duplicates (same term and termpos) will be removed.
const Xapian::Query Xapian::Query::MatchAll [static] |
A query which matches all documents in the database.
const Xapian::Query Xapian::Query::MatchNothing [static] |
A query which matches no documents.