#include <matchspy.h>
Inheritance diagram for Xapian::CategorySelectMatchSpy:
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. |
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().
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.
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. |
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).
valno | Value number to produce ranges for. | |
max_ranges | Group into at most this many ranges. |