

Public Types | |
| 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 | |
| Internal (const Query::Internal ©me) | |
| Copy constructor. | |
| void | operator= (const Query::Internal ©me) |
| Assignment. | |
| Internal (const std::string &tname_, Xapian::termcount wqf_=1, Xapian::termpos term_pos_=0) | |
| A query consisting of a single term. | |
| Internal (op_t op_, Xapian::termcount parameter) | |
| Create internals given only the operator and a parameter. | |
| Internal (op_t op_, Xapian::valueno slot, const std::string &begin, const std::string &end) | |
| Construct a range query on a document value. | |
| Internal (op_t op_, Xapian::valueno slot, const std::string &value) | |
| Construct a value greater-than-or-equal query on a document value. | |
| Internal (Xapian::PostingSource *external_source_, bool owned) | |
| Construct an external source query. | |
| ~Internal () | |
| Destructor. | |
| void | add_subquery (const Query::Internal *subq) |
| Add a subquery. | |
| void | add_subquery_nocopy (Query::Internal *subq) |
| Add a subquery without copying it. | |
| void | set_dbl_parameter (double dbl_parameter_) |
| double | get_dbl_parameter () const |
| Query::Internal * | end_construction () |
| Finish off the construction. | |
| std::string | serialise () const |
| Return a string in an easily parsed form which contains all the information in a query. | |
| std::string | get_description () const |
| Return a string describing this object. | |
| Xapian::termcount | get_parameter () const |
| Get the numeric parameter used in this query. | |
| Xapian::termcount | get_wqf () const |
| Xapian::termcount | get_length () const |
| Get the length of the query, used by some ranking formulae. | |
| TermIterator | get_terms () const |
| Return an iterator over all the terms in the query, in order of termpos. | |
Static Public Member Functions | |
| static Xapian::Query::Internal * | unserialise (const std::string &s, const Registry ®istry) |
Static Public Attributes | |
| static const int | OP_LEAF = -1 |
| static const int | OP_EXTERNAL_SOURCE = -2 |
Private Member Functions | |
| void | initialise_from_copy (const Query::Internal ©me) |
| Copy another Xapian::Query::Internal into self. | |
| void | accumulate_terms (std::vector< std::pair< std::string, Xapian::termpos > > &terms) const |
| Internal * | simplify_query () |
| Simplify the query. | |
| void | validate_query () const |
| Perform checks that query is valid. | |
| bool | simplify_matchnothing () |
| Simplify any matchnothing subqueries, either eliminating them, or setting this query to matchnothing, depending on the query operator. | |
| void | collapse_subqs () |
| Collapse the subqueries together if appropriate. | |
| Xapian::Query::Internal * | flatten_subqs () |
| Flatten a query structure, by changing, for example, "A NEAR (B AND C)" to "(A NEAR B) AND (A NEAR C)". | |
| std::string | serialise (Xapian::termpos &curpos) const |
| Implementation of serialisation; called recursively. | |
Static Private Member Functions | |
| static std::string | get_op_name (Xapian::Query::Internal::op_t op) |
| Get a string describing the given query type. | |
Private Attributes | |
| Xapian::Query::Internal::op_t | op |
| Operation to be performed at this node. | |
| subquery_list | subqs |
| Sub queries on which to perform operation. | |
| Xapian::termcount | parameter |
| For NEAR or PHRASE, how close terms must be to match: all terms within the operation must occur in a window of this size. | |
| std::string | tname |
| Term that this node represents, or start of a range query. | |
| std::string | str_parameter |
| Used to store the end of a range query. | |
| Xapian::termpos | term_pos |
| Position in query of this term - leaf node only. | |
| Xapian::PostingSource * | external_source |
| External posting source. | |
| bool | external_source_owned |
| Flag, indicating whether the external source is owned by the query. | |
Friends | |
| class | ::LocalSubMatch |
| class | ::MultiMatch |
| class | ::QueryOptimiser |
| struct | ::SortPosName |
| class | Query |
For internal use only.
Internal class, implementing most of Xapian::Query.
Definition at line 375 of file query.h.
| typedef int Xapian::Query::Internal::op_t |
| typedef std::vector<Internal *> Xapian::Query::Internal::subquery_list |
| Xapian::Query::Internal::Internal | ( | const Query::Internal & | copyme | ) |
Copy constructor.
Definition at line 644 of file omqueryinternal.cc.
References Xapian::PostingSource::clone(), external_source, external_source_owned, and subqs.
| Xapian::Query::Internal::Internal | ( | const std::string & | tname_, | |
| Xapian::termcount | wqf_ = 1, |
|||
| Xapian::termpos | term_pos_ = 0 | |||
| ) | [explicit] |
A query consisting of a single term.
Definition at line 674 of file omqueryinternal.cc.
References validate_query().
| Xapian::Query::Internal::Internal | ( | op_t | op_, | |
| Xapian::termcount | parameter | |||
| ) |
Create internals given only the operator and a parameter.
Definition at line 687 of file omqueryinternal.cc.
References Xapian::Query::OP_ELITE_SET, Xapian::Query::OP_NEAR, Xapian::Query::OP_PHRASE, and parameter.
| Xapian::Query::Internal::Internal | ( | op_t | op_, | |
| Xapian::valueno | slot, | |||
| const std::string & | begin, | |||
| const std::string & | end | |||
| ) |
Construct a range query on a document value.
Definition at line 700 of file omqueryinternal.cc.
References Xapian::Query::OP_VALUE_RANGE, and validate_query().
| Xapian::Query::Internal::Internal | ( | op_t | op_, | |
| Xapian::valueno | slot, | |||
| const std::string & | value | |||
| ) |
Construct a value greater-than-or-equal query on a document value.
Definition at line 714 of file omqueryinternal.cc.
References OP_LEAF, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, parameter, term_pos, and validate_query().
| Xapian::Query::Internal::Internal | ( | Xapian::PostingSource * | external_source_, | |
| bool | owned | |||
| ) | [explicit] |
Construct an external source query.
Definition at line 733 of file omqueryinternal.cc.
References Assert, and external_source.
| Xapian::Query::Internal::~Internal | ( | ) |
Destructor.
Definition at line 740 of file omqueryinternal.cc.
References external_source, external_source_owned, and subqs.
| void Xapian::Query::Internal::accumulate_terms | ( | std::vector< std::pair< std::string, Xapian::termpos > > & | terms | ) | const [private] |
Referenced by get_terms().
| void Xapian::Query::Internal::add_subquery | ( | const Query::Internal * | subq | ) |
Add a subquery.
Definition at line 1038 of file omqueryinternal.cc.
References Assert, is_distributable(), is_leaf(), op, and subqs.
Referenced by add_subquery_nocopy().
| void Xapian::Query::Internal::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.
Definition at line 1055 of file omqueryinternal.cc.
References add_subquery(), Assert, is_distributable(), is_leaf(), op, and subqs.
Referenced by qint_from_vector().
| void Xapian::Query::Internal::collapse_subqs | ( | ) | [private] |
Collapse the subqueries together if appropriate.
Collapse occurrences of a term at the same position into a single occurrence with higher wqf.
Definition at line 946 of file omqueryinternal.cc.
References Assert, AssertEq, is_leaf(), Xapian::Query::OP_AND, Xapian::Query::OP_OR, Xapian::Query::OP_SYNONYM, Xapian::Query::OP_XOR, and subqs.
Referenced by simplify_query().
| Xapian::Query::Internal * Xapian::Query::Internal::end_construction | ( | ) |
Finish off the construction.
Definition at line 752 of file omqueryinternal.cc.
References LOGCALL_VOID, simplify_query(), and validate_query().
Referenced by qint_from_vector().
| Xapian::Query::Internal * Xapian::Query::Internal::flatten_subqs | ( | ) | [private] |
Flatten a query structure, by changing, for example, "A NEAR (B AND C)" to "(A NEAR B) AND (A NEAR C)".
Change, eg, A NEAR (B AND C) to (A NEAR B) AND (A NEAR C).
Definition at line 980 of file omqueryinternal.cc.
References Assert, is_leaf(), op, Xapian::Query::OP_AND, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_XOR, and subqs.
Referenced by simplify_query().
| double Xapian::Query::Internal::get_dbl_parameter | ( | ) | const |
Definition at line 1083 of file omqueryinternal.cc.
References str_parameter, and unserialise_double().
Referenced by QueryOptimiser::do_subquery(), get_description(), simplify_query(), and validate_query().
| string Xapian::Query::Internal::get_description | ( | ) | const |
Return a string describing this object.
Definition at line 279 of file omqueryinternal.cc.
References external_source, get_dbl_parameter(), Xapian::PostingSource::get_description(), get_op_name(), is_leaf(), Xapian::Query::OP_ELITE_SET, OP_EXTERNAL_SOURCE, Xapian::Query::OP_NEAR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, Xapian::Query::OP_VALUE_RANGE, parameter, Xapian::Internal::str(), str_parameter, subqs, term_pos, and tname.
| Xapian::termcount Xapian::Query::Internal::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().
Definition at line 344 of file omqueryinternal.cc.
| string Xapian::Query::Internal::get_op_name | ( | Xapian::Query::Internal::op_t | op | ) | [static, private] |
Get a string describing the given query type.
Definition at line 253 of file omqueryinternal.cc.
References Xapian::Query::OP_AND, Xapian::Query::OP_AND_MAYBE, Xapian::Query::OP_AND_NOT, Xapian::Query::OP_ELITE_SET, OP_EXTERNAL_SOURCE, Xapian::Query::OP_FILTER, OP_LEAF, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_SYNONYM, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, Xapian::Query::OP_VALUE_RANGE, and Xapian::Query::OP_XOR.
Referenced by get_description(), and validate_query().
| Xapian::termcount Xapian::Query::Internal::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::TermIterator Xapian::Query::Internal::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.
Definition at line 389 of file omqueryinternal.cc.
References accumulate_terms().
Referenced by Xapian::Weight::Internal::mark_wanted_terms().
| Xapian::termcount Xapian::Query::Internal::get_wqf | ( | ) | const [inline] |
Definition at line 540 of file query.h.
Referenced by QueryOptimiser::do_synonym(), and LocalSubMatch::postlist_from_op_leaf_query().
| void Xapian::Query::Internal::initialise_from_copy | ( | const Query::Internal & | copyme | ) | [private] |
Copy another Xapian::Query::Internal into self.
| void Xapian::Query::Internal::operator= | ( | const Query::Internal & | copyme | ) |
Assignment.
| std::string Xapian::Query::Internal::serialise | ( | ) | const [inline] |
| string Xapian::Query::Internal::serialise | ( | Xapian::termpos & | curpos | ) | const [private] |
Implementation of serialisation; called recursively.
serialising method, for network matches.
The format is designed to be relatively easy to parse.
A single-term query becomes `[<encodedtname><termpos>#<wqf>' where: <wqf> is the decimal within query frequency (1 if omitted), <termpos> is the decimal term position (index of term if omitted).
A compound query becomes `(<subqueries><op>', where: <subqueries> is the list of subqueries <op> is one of: &|+-^ also ~N "N >F *N (N unsigned int; F floating point)
If querylen != sum(wqf) we append `=len' (at present we always do this for compound queries as it's simpler than working out what sum(wqf) would be - FIXME).
Definition at line 152 of file omqueryinternal.cc.
References Assert, encode_length(), external_source, Xapian::PostingSource::name(), Xapian::Query::OP_AND, Xapian::Query::OP_AND_MAYBE, Xapian::Query::OP_AND_NOT, Xapian::Query::OP_ELITE_SET, OP_EXTERNAL_SOURCE, Xapian::Query::OP_FILTER, OP_LEAF, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_SYNONYM, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, Xapian::Query::OP_VALUE_RANGE, Xapian::Query::OP_XOR, parameter, Xapian::PostingSource::serialise(), str_parameter, subqs, term_pos, and tname.
Referenced by serialisequery1_helper(), RemoteDatabase::set_query(), and unserialise().
| void Xapian::Query::Internal::set_dbl_parameter | ( | double | dbl_parameter_ | ) |
Definition at line 1073 of file omqueryinternal.cc.
References serialise_double(), and str_parameter.
Referenced by qint_from_vector().
| bool Xapian::Query::Internal::simplify_matchnothing | ( | ) | [private] |
Simplify any matchnothing subqueries, either eliminating them, or setting this query to matchnothing, depending on the query operator.
Returns true if simplification resulted in a matchnothing query.
Definition at line 790 of file omqueryinternal.cc.
References Assert, Xapian::Query::OP_AND, Xapian::Query::OP_AND_MAYBE, Xapian::Query::OP_AND_NOT, Xapian::Query::OP_ELITE_SET, Xapian::Query::OP_FILTER, OP_LEAF, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_SYNONYM, Xapian::Query::OP_XOR, and subqs.
Referenced by simplify_query().
| Xapian::Query::Internal * Xapian::Query::Internal::simplify_query | ( | ) | [private] |
Simplify the query.
For example, an AND query with only one subquery would become the subquery itself.
Definition at line 856 of file omqueryinternal.cc.
References Assert, collapse_subqs(), flatten_subqs(), get_dbl_parameter(), LOGCALL, Xapian::Query::OP_AND, Xapian::Query::OP_ELITE_SET, OP_LEAF, Xapian::Query::OP_NEAR, Xapian::Query::OP_OR, Xapian::Query::OP_PHRASE, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_SYNONYM, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, Xapian::Query::OP_VALUE_RANGE, Xapian::Query::OP_XOR, parameter, simplify_matchnothing(), str_parameter, subqs, and tname.
Referenced by end_construction().
| Xapian::Query::Internal * Xapian::Query::Internal::unserialise | ( | const std::string & | s, | |
| const Registry & | registry | |||
| ) | [static] |
Definition at line 627 of file omqueryinternal.cc.
References Assert, AssertEq, and serialise().
Referenced by RemoteServer::msg_query(), and serialisequery1_helper().
| void Xapian::Query::Internal::validate_query | ( | ) | const [private] |
Perform checks that query is valid.
(e.g., has correct number of sub queries.) Throw an exception if not. This is initially called on the query before any simplifications have been made, and after simplifications.
Definition at line 762 of file omqueryinternal.cc.
References Assert, get_dbl_parameter(), get_max_subqs(), get_min_subqs(), get_op_name(), is_leaf(), LOGCALL_VOID, Xapian::Query::OP_SCALE_WEIGHT, Xapian::Query::OP_VALUE_GE, Xapian::Query::OP_VALUE_LE, Xapian::Query::OP_VALUE_RANGE, Xapian::Internal::str(), subqs, and tname.
Referenced by end_construction(), Internal(), and MultiMatch::MultiMatch().
friend class ::LocalSubMatch [friend] |
friend class ::MultiMatch [friend] |
friend class ::QueryOptimiser [friend] |
friend struct ::SortPosName [friend] |
External posting source.
Definition at line 424 of file query.h.
Referenced by QueryOptimiser::do_subquery(), get_description(), Internal(), serialise(), and ~Internal().
bool Xapian::Query::Internal::external_source_owned [private] |
Flag, indicating whether the external source is owned by the query.
Definition at line 427 of file query.h.
Referenced by Internal(), and ~Internal().
Operation to be performed at this node.
Definition at line 393 of file query.h.
Referenced by add_subquery(), add_subquery_nocopy(), QueryOptimiser::do_and_like(), QueryOptimiser::do_or_like(), QueryOptimiser::do_subquery(), flatten_subqs(), SortPosName::operator()(), and LocalSubMatch::postlist_from_op_leaf_query().
const int Xapian::Query::Internal::OP_EXTERNAL_SOURCE = -2 [static] |
Definition at line 383 of file query.h.
Referenced by QueryOptimiser::do_subquery(), get_description(), get_max_subqs(), get_min_subqs(), get_op_name(), and serialise().
const int Xapian::Query::Internal::OP_LEAF = -1 [static] |
Definition at line 382 of file query.h.
Referenced by QueryOptimiser::do_subquery(), get_max_subqs(), get_min_subqs(), get_op_name(), Internal(), is_leaf(), LocalSubMatch::postlist_from_op_leaf_query(), serialise(), simplify_matchnothing(), and simplify_query().
For NEAR or PHRASE, how close terms must be to match: all terms within the operation must occur in a window of this size.
For ELITE_SET, the number of terms to select from those specified.
For RANGE, the value number to apply the range test to.
For a leaf node, this is the within query frequency of the term.
Definition at line 407 of file query.h.
Referenced by QueryOptimiser::do_and_like(), QueryOptimiser::do_or_like(), QueryOptimiser::do_subquery(), get_description(), get_length(), Internal(), serialise(), and simplify_query().
std::string Xapian::Query::Internal::str_parameter [private] |
Used to store the end of a range query.
Definition at line 418 of file query.h.
Referenced by QueryOptimiser::do_subquery(), get_dbl_parameter(), get_description(), serialise(), set_dbl_parameter(), and simplify_query().
subquery_list Xapian::Query::Internal::subqs [private] |
Sub queries on which to perform operation.
Definition at line 396 of file query.h.
Referenced by add_subquery(), add_subquery_nocopy(), collapse_subqs(), QueryOptimiser::do_and_like(), QueryOptimiser::do_or_like(), QueryOptimiser::do_subquery(), flatten_subqs(), get_description(), get_length(), Internal(), LocalSubMatch::postlist_from_op_leaf_query(), serialise(), simplify_matchnothing(), simplify_query(), validate_query(), and ~Internal().
Position in query of this term - leaf node only.
Definition at line 421 of file query.h.
Referenced by get_description(), Internal(), SortPosName::operator()(), and serialise().
std::string Xapian::Query::Internal::tname [private] |
Term that this node represents, or start of a range query.
For a leaf node, this holds the term name. For an OP_VALUE_RANGE query this holds the start of the range. For an OP_VALUE_GE or OP_VALUE_LE query this holds the value to compare against.
Definition at line 415 of file query.h.
Referenced by QueryOptimiser::do_subquery(), get_description(), SortPosName::operator()(), LocalSubMatch::postlist_from_op_leaf_query(), serialise(), simplify_query(), and validate_query().