xapian-core  1.4.24
Public Member Functions | List of all members
Xapian::NumberRangeProcessor Class Reference

Handle a number range. More...

#include <queryparser.h>

+ Inheritance diagram for Xapian::NumberRangeProcessor:

Public Member Functions

 NumberRangeProcessor (Xapian::valueno slot_, const std::string &str_=std::string(), unsigned flags_=0)
 Constructor.
 
Xapian::Query operator() (const std::string &begin, const std::string &end)
 Check for a valid numeric range.
 
- Public Member Functions inherited from Xapian::RangeProcessor
 RangeProcessor ()
 Default constructor.
 
 RangeProcessor (Xapian::valueno slot_, const std::string &str_=std::string(), unsigned flags_=0)
 Constructor.
 
virtual ~RangeProcessor ()
 Destructor.
 
Xapian::Query check_range (const std::string &b, const std::string &e)
 Check prefix/suffix on range.
 
RangeProcessorrelease ()
 Start reference counting this object.
 
const RangeProcessorrelease () const
 Start reference counting this object.
 

Additional Inherited Members

- Protected Attributes inherited from Xapian::RangeProcessor
Xapian::valueno slot
 The value slot to process.
 
std::string str
 The prefix (or suffix with RP_SUFFIX) string to look for.
 
unsigned flags
 Flags.
 

Detailed Description

Handle a number range.

This class must be used on values which have been encoded using Xapian::sortable_serialise() which turns numbers into strings which will sort in the same order as the numbers (the same values can be used to implement a numeric sort).

Constructor & Destructor Documentation

◆ NumberRangeProcessor()

Xapian::NumberRangeProcessor::NumberRangeProcessor ( Xapian::valueno  slot_,
const std::string &  str_ = std::string(),
unsigned  flags_ = 0 
)
inline

Constructor.

Parameters
slot_The value slot number to query.
str_A string to look for to recognise values as belonging to this numeric range.
flags_Zero or more of the following flags, combined with bitwise-or:
  • Xapian::RP_SUFFIX - require str_ as a suffix instead of a prefix.
  • Xapian::RP_REPEATED - optionally allow str_ on both ends of the range - e.g. $1..$10 or 5m..50m. By default a prefix is only checked for on the start (e.g. date:1/1/1980..31/12/1989), and a suffix only on the end (e.g. 2..12kg).

The string supplied in str_ is used by operator() to decide whether the pair of strings supplied to it constitute a valid range. If prefix_ is true, the first value in a range must begin with str_ (and the second value may optionally begin with str_); if prefix_ is false, the second value in a range must end with str_ (and the first value may optionally end with str_).

If str_ is empty, the setting of prefix_ is irrelevant, and no special strings are required at the start or end of the strings defining the range.

The remainder of both strings defining the endpoints must be valid floating point numbers. (FIXME: define format recognised).

For example, if str_ is "$" and prefix_ is true, and the range processor has been added to the queryparser, the queryparser will accept "$10..50" or "$10..$50", but not "10..50" or "10..$50" as valid ranges. If str_ is "kg" and prefix_ is false, the queryparser will accept "10..50kg" or "10kg..50kg", but not "10..50" or "10kg..50" as valid ranges.

Member Function Documentation

◆ operator()()

Xapian::Query Xapian::NumberRangeProcessor::operator() ( const std::string &  begin,
const std::string &  end 
)
virtual

Check for a valid numeric range.

If BEGIN..END is a valid numeric range with the specified prefix/suffix (if one was specified), the prefix/suffix is removed, the string converted to a number, and encoded with Xapian::sortable_serialise(), and a value range query is built.

Parameters
beginThe start of the range as specified in the query string by the user.
endThe end of the range as specified in the query string by the user.

Reimplemented from Xapian::RangeProcessor.


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