Public Types | Public Member Functions
Xapian::Query Class Reference

Class representing a query. More...

List of all members.

Public Types

enum  op { , OP_ELITE_SET = 10 }
 Query operators. More...

Public Member Functions

 Query ()
 Default constructor.
 ~Query ()
 Destructor.
 Query (const Query &o)
 Copying is allowed.
Queryoperator= (const Query &o)
 Copying is allowed.
 Query (const std::string &term, Xapian::termcount wqf=1, Xapian::termpos pos=0)
 Construct a Query object for a term.
 Query (Xapian::PostingSource *source)
 Construct a Query object for a PostingSource.

Detailed Description

Class representing a query.


Member Enumeration Documentation

Query operators.

Enumerator:
OP_ELITE_SET 

Pick the best N subqueries and combine with OP_OR.

If you want to implement a feature which finds documents similar to a piece of text, an obvious approach is to build an "OR" query from all the terms in the text, and run this query against a database containing the documents. However such a query can contain a lots of terms and be quite slow to perform, yet many of these terms don't contribute usefully to the results.

The OP_ELITE_SET operator can be used instead of OP_OR in this situation. OP_ELITE_SET selects the most important ''N'' terms and then acts as an OP_OR query with just these, ignoring any other terms. This will usually return results just as good as the full OP_OR query, but much faster.

In general, the OP_ELITE_SET operator can be used when you have a large OR query, but it doesn't matter if the search completely ignores some of the less important terms in the query.

The subqueries don't have to be terms, but if they aren't then OP_ELITE_SET will look at the estimated frequencies of the subqueries and so could pick a subset which don't actually match any documents even if the full OR would match some.

You can specify a parameter to the query constructor which control the number of terms which OP_ELITE_SET will pick. If not specified, this defaults to 10 (Xapian used to default to ceil(sqrt(number_of_subqueries)) if there are more than 100 subqueries, but this rather arbitrary special case was dropped in 1.3.0). For example, this will pick the best 7 terms:

  Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin(), subqs.end(), 7);
  

If the number of subqueries is less than this threshold, OP_ELITE_SET behaves identically to OP_OR.


Constructor & Destructor Documentation

Xapian::Query::Query ( const Query o) [inline]

Copying is allowed.

The internals are reference counted, so copying is cheap.

Xapian::Query::Query ( const std::string &  term,
Xapian::termcount  wqf = 1,
Xapian::termpos  pos = 0 
)

Construct a Query object for a term.

Construct a Query object for a PostingSource.


Member Function Documentation

Query& Xapian::Query::operator= ( const Query o) [inline]

Copying is allowed.

The internals are reference counted, so assignment is cheap.


The documentation for this class was generated from the following file:

Documentation for Xapian (version 1.3.1).
Generated on Fri May 3 2013 by Doxygen 1.7.6.1.