Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Xapian::Query Class Reference

Class representing a query. More...

#include <query.h>

Collaboration diagram for Xapian::Query:

Collaboration graph
[legend]
List of all members.

Public Types

enum  op {
  OP_AND, OP_OR, OP_AND_NOT, OP_XOR,
  OP_AND_MAYBE, OP_FILTER, OP_NEAR, OP_PHRASE,
  OP_WEIGHT_CUTOFF, OP_ELITE_SET
}
 Enum of possible query operations. More...


Public Methods

 Query (const Query &copyme)
 Copy constructor. More...

Query & operator= (const Query &copyme)
 Assignment. More...

 Query ()
 Default constructor: makes an empty query which matches no documents. More...

 ~Query ()
 Destructor. More...

 Query (const std::string &tname_, Xapian::termcount wqf_=1, Xapian::termpos pos_=0)
 A query consisting of a single term. More...

 Query (Query::op op_, const Query &left, const Query &right)
 A query consisting of two subqueries, opp-ed together. More...

 Query (Query::op op_, const std::string &left, const std::string &right)
 A query consisting of two termnames opp-ed together. More...

template<class Iterator>  Query (Query::op op_, Iterator qbegin, Iterator qend)
 Combine a number of Xapian::Query-s with the specified operator. More...

template<class SubQ>  Query (Query::op op_, SubQ q)
 Apply the specified operator to a single Xapian::Query object. More...

void set_window (Xapian::termpos window)
 Set the window size, for a NEAR or PHRASE query. More...

void set_cutoff (Xapian::weight cutoff)
 Set the cutoff parameter, for a WEIGHT_CUTOFF query. More...

void set_elite_set_size (Xapian::termcount size)
 Set the elite set size, for ELITE_SET queries. More...

Xapian::termcount get_length () const
 Get the length of the query, used by some ranking formulae. More...

Xapian::termcount set_length (Xapian::termcount qlen)
 Set the length of the query. More...

TermIterator get_terms_begin () const
 Return a Xapian::TermIterator returning all the terms in the query, in order of termpos. More...

TermIterator get_terms_end () const
 Return a Xapian::TermIterator to the end of the list of terms in the query. More...

bool is_empty () const
 Test is the query is empty (i.e. More...

std::string get_description () const
 Returns a string representing the query. More...


Public Attributes

Xapian::Internal::RefCntPtr<
Internal
internal

Detailed Description

Class representing a query.

Queries are represented as a tree of objects.


Member Enumeration Documentation

enum Xapian::Query::op
 

Enum of possible query operations.

Enumeration values:
OP_AND  Return iff both subqueries are satisfied.
OP_OR  Return if either subquery is satisfied.
OP_AND_NOT  Return if left but not right satisfied.
OP_XOR  Return if one query satisfied, but not both.
OP_AND_MAYBE  Return iff left satisfied, but use weights from both.
OP_FILTER  As AND, but use only weights from left subquery.
OP_NEAR  Find occurrences of a list of terms with all the terms occurring within a specified window of positions.

Each occurrence of a term must be at a different position, but the order they appear in is irrelevant.

The window parameter should be specified for this operation, but will default to the number of terms in the list.

OP_PHRASE  Find occurrences of a list of terms with all the terms occurring within a specified window of positions, and all the terms appearing in the order specified.

Each occurrence of a term must be at a different position.

The window parameter should be specified for this operation, but will default to the number of terms in the list.

OP_WEIGHT_CUTOFF  Return only results with a weight greater than or equal to a specified cutoff value.

The cutoff parameter should be specified for this operation, and will default to 0 (no cutoff).

OP_ELITE_SET  Select an elite set of terms from the subqueries, and perform a query with all those terms combined as an OR query.


Constructor & Destructor Documentation

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.

Xapian::Query::Query Query::op    op_,
const Query &    left,
const Query &    right
 

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.

template<class Iterator>
Xapian::Query::Query Query::op    op_,
Iterator    qbegin,
Iterator    qend
 

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. WEIGHT_CUTOFF takes only one subquery. Other operators take exactly two subqueries.

The iterators may be to Xapian::Query objects, pointers to Xapian::Query objects, or termnames (std::string-s).

template<class SubQ>
Xapian::Query::Query Query::op    op_,
SubQ    q
 

Apply the specified operator to a single Xapian::Query object.

The subquery may a Xapian::Query object, a pointer to a Xapian::Query object or std::string.


Member Function Documentation

std::string Xapian::Query::get_description   const
 

Returns a string representing the query.

Introspection method.

Xapian::termcount Xapian::Query::get_length   const
 

Get the length of the query, used by some ranking formulae.

This value is calculated automatically, but may be overridden using set_length().

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
 

Return a Xapian::TermIterator to the end of the list of terms in the query.

bool Xapian::Query::is_empty   const
 

Test is the query is empty (i.e.

was constructed using the default ctor or with an empty iterator ctor).

Query& Xapian::Query::operator= const Query &    copyme
 

Assignment.

void Xapian::Query::set_cutoff Xapian::weight    cutoff
 

Set the cutoff parameter, for a WEIGHT_CUTOFF query.

void Xapian::Query::set_elite_set_size Xapian::termcount    size
 

Set the elite set size, for ELITE_SET queries.

Xapian::termcount Xapian::Query::set_length Xapian::termcount    qlen
 

Set the length of the query.

This overrides the automatically calculated value, which may be desirable in some situations. Returns the old value of the query length.

void Xapian::Query::set_window Xapian::termpos    window
 

Set the window size, for a NEAR or PHRASE query.


The documentation for this class was generated from the following file:
Documentation for Xapian (version 0.8.0).
Generated on 20 Apr 2004 by Doxygen 1.2.15.