Xapian::CategorySelectMatchSpy Class Reference

MatchSpy for classifying matching documents by their values. More...

#include <matchspy.h>

Inheritance diagram for Xapian::CategorySelectMatchSpy:

Inheritance graph
[legend]
Collaboration diagram for Xapian::CategorySelectMatchSpy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CategorySelectMatchSpy ()
 Default constructor.
 CategorySelectMatchSpy (Xapian::valueno valno)
 Construct a MatchSpy which classifies matching documents based on the values in a particular slot.
double score_categorisation (Xapian::valueno valno, double desired_no_of_categories=0.0)
 Return a score reflecting how "good" a categorisation is.
bool build_numeric_ranges (Xapian::valueno valno, size_t max_ranges)
 Turn a category containing sort-encoded numeric values into a set of ranges.

Detailed Description

MatchSpy for classifying matching documents by their values.


Constructor & Destructor Documentation

Xapian::CategorySelectMatchSpy::CategorySelectMatchSpy (  )  [inline]

Default constructor.

Xapian::CategorySelectMatchSpy::CategorySelectMatchSpy ( Xapian::valueno  valno  )  [inline]

Construct a MatchSpy which classifies matching documents based on the values in a particular slot.

Further slots can be added by calling add_slot().


Member Function Documentation

double Xapian::CategorySelectMatchSpy::score_categorisation ( Xapian::valueno  valno,
double  desired_no_of_categories = 0.0 
)

Return a score reflecting how "good" a categorisation is.

If you don't want to show a poor categorisation, or have multiple categories and only space in your user interface to show a few, you want to be able to decide how "good" a categorisation is. We define a good categorisation as one which offers a fairly even split, and (optionally) about a specified number of options.

Parameters:
valno Value number to look at the categorisation for.
desired_no_of_categories The desired number of categories - this is a floating point value, so you can ask for 5.5 if you'd like "about 5 or 6 categories". The default is to desire the number of categories that there actually are, so the score then only reflects how even the split is.
Returns:
A score for the categorisation for value valno - lower is better, with a perfectly even split across the right number of categories scoring 0.

bool Xapian::CategorySelectMatchSpy::build_numeric_ranges ( Xapian::valueno  valno,
size_t  max_ranges 
)

Turn a category containing sort-encoded numeric values into a set of ranges.

For "continuous" values (such as price, height, weight, etc), there will usually be too many different values to offer the user, and the user won't want to restrict to an exact value anyway.

This method produces a set of ranges for a particular value number. The ranges replace the category data for value valno - the keys are either empty (entry for "no value set"), <= 9 bytes long (a singleton encoded value), or > 9 bytes long (the first 9 bytes are the encoded range start, the rest the encoded range end).

Parameters:
valno Value number to produce ranges for.
max_ranges Group into at most this many ranges.
Returns:
true if ranges could be built; false if not (e.g. all values the same, no values set, or other reasons).


The documentation for this class was generated from the following file:
Documentation for Xapian (version 1.0.10).
Generated on 23 Dec 2008 by Doxygen 1.5.2.