23 #ifndef XAPIAN_INCLUDED_QUERYPARSER_H
24 #define XAPIAN_INCLUDED_QUERYPARSER_H
26 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
27 # error Never use <xapian/queryparser.h> directly; include <xapian.h> instead.
66 virtual bool operator()(
const std::string & term)
const = 0;
72 virtual std::string get_description()
const;
82 opt_intrusive_base::release();
94 opt_intrusive_base::release();
120 template<
class Iterator>
124 void add(
const std::string & word) { stop_words.insert(word); }
127 return stop_words.find(term) != stop_words.end();
130 virtual std::string get_description()
const;
192 const std::string& str_ = std::string(),
194 : slot(slot_),
str(str_), flags(flags_) { }
204 Xapian::Query check_range(
const std::string& b,
const std::string& e);
222 operator()(
const std::string &begin,
const std::string &end);
232 opt_intrusive_base::release();
244 opt_intrusive_base::release();
272 int epoch_year_ = 1970)
274 epoch_year(epoch_year_) { }
318 unsigned flags_ = 0,
int epoch_year_ = 1970)
320 epoch_year(epoch_year_) { }
333 Xapian::Query operator()(
const std::string& begin,
const std::string& end);
384 const std::string &str_ = std::string(),
400 Xapian::Query operator()(
const std::string& begin,
const std::string& end);
443 opt_intrusive_base::release();
455 opt_intrusive_base::release();
483 : valno(slot_),
str() { }
495 : valno(slot_), prefix(prefix_),
str(str_) { }
536 int epoch_year_ = 1970)
538 prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { }
579 bool prefer_mdy_ =
false,
int epoch_year_ = 1970)
581 prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { }
630 bool prefer_mdy_ =
false,
int epoch_year_ = 1970)
632 prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { }
760 opt_intrusive_base::release();
772 opt_intrusive_base::release();
794 FLAG_BOOLEAN_ANY_CASE = 8,
852 FLAG_SPELLING_CORRECTION = 128,
864 FLAG_AUTO_SYNONYMS = 512,
871 FLAG_AUTO_MULTIWORD_SYNONYMS = 1024,
904 FLAG_CJK_NGRAM = FLAG_NGRAMS,
919 FLAG_ACCUMULATE = 65536,
930 FLAG_NO_POSITIONS = 0x20000,
939 FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE
944 STEM_NONE, STEM_SOME,
STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS
953 #ifdef XAPIAN_MOVE_SEMANTICS
1004 void set_stemming_strategy(stem_strategy strategy);
1011 void set_stopper(
const Stopper *stop = NULL);
1027 void set_default_op(
Query::op default_op);
1038 void set_database(
const Database &db);
1068 unsigned flags = FLAG_WILDCARD|FLAG_PARTIAL);
1107 Query parse_query(
const std::string &query_string,
1108 unsigned flags = FLAG_DEFAULT,
1109 const std::string &default_prefix = std::string());
1155 void add_prefix(
const std::string& field,
const std::string& prefix);
1220 void add_boolean_prefix(
const std::string &field,
const std::string &prefix,
1221 const std::string*
grouping = NULL);
1248 add_boolean_prefix(field, prefix);
1250 std::string empty_grouping;
1251 add_boolean_prefix(field, prefix, &empty_grouping);
1258 const std::string*
grouping = NULL);
1268 add_boolean_prefix(field, proc);
1270 std::string empty_grouping;
1271 add_boolean_prefix(field, proc, &empty_grouping);
1284 TermIterator unstem_begin(
const std::string &term)
const;
1293 const std::string*
grouping = NULL);
1303 # pragma GCC diagnostic push
1304 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
1315 operator()(
const std::string &begin,
const std::string &end)
1317 std::string b = begin, e = end;
1318 slot = (*vrp)(b, e);
1325 add_rangeprocessor((
new ShimRangeProcessor(vrproc))->release());
1327 # pragma GCC diagnostic pop
1338 std::string get_corrected_query_string()
const;
1341 std::string get_description()
const;
Compiler attribute macros.
This class is used to access a database, or a group of databases.
DateRangeProcessor(Xapian::valueno slot_, const std::string &str_, unsigned flags_=0, int epoch_year_=1970)
Constructor.
DateRangeProcessor(Xapian::valueno slot_, unsigned flags_=0, int epoch_year_=1970)
Constructor.
DateValueRangeProcessor(Xapian::valueno slot_, const char *str_, bool prefix_=true, bool prefer_mdy_=false, int epoch_year_=1970)
Constructor.
DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, bool prefix_=true, bool prefer_mdy_=false, int epoch_year_=1970)
Constructor.
DateValueRangeProcessor(Xapian::valueno slot_, bool prefer_mdy_=false, int epoch_year_=1970)
Constructor.
Base class for field processors.
FieldProcessor * release()
Start reference counting this object.
const FieldProcessor * release() const
Start reference counting this object.
FieldProcessor(const FieldProcessor &)
Don't allow copying.
void operator=(const FieldProcessor &)
Don't allow assignment.
FieldProcessor()
Default constructor.
virtual Xapian::Query operator()(const std::string &str)=0
Convert a field-prefixed string to a Query object.
A smart pointer that uses intrusive reference counting.
Base class for objects managed by opt_intrusive_ptr.
A smart pointer that optionally uses intrusive reference counting.
NumberRangeProcessor(Xapian::valueno slot_, const std::string &str_=std::string(), unsigned flags_=0)
Constructor.
NumberValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, bool prefix_=true)
Constructor.
NumberValueRangeProcessor(Xapian::valueno slot_)
Constructor.
Build a Xapian::Query object from a user query string.
void set_max_wildcard_expansion(Xapian::termcount)
Specify the maximum expansion of a wildcard.
void set_max_expansion(Xapian::termcount max_expansion, int max_type=Xapian::Query::WILDCARD_LIMIT_ERROR, unsigned flags=FLAG_WILDCARD|FLAG_PARTIAL)
Specify the maximum expansion of a wildcard and/or partial term.
TermIterator stoplist_end() const
End iterator over terms omitted from the query as stopwords.
void add_boolean_prefix(const std::string &field, const std::string &prefix, bool exclusive)
Add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in t...
void add_valuerangeprocessor(Xapian::ValueRangeProcessor *vrproc)
Register a ValueRangeProcessor.
@ FLAG_WILDCARD
Support wildcards.
void add_boolean_prefix(const std::string &field, Xapian::FieldProcessor *proc, bool exclusive)
Register a FieldProcessor for a boolean prefix.
TermIterator unstem_end(const std::string &) const
End iterator over unstemmed forms of the given stemmed query term.
Class representing a query.
@ WILDCARD_LIMIT_ERROR
Throw an error if OP_WILDCARD exceeds its expansion limit.
@ OP_INVALID
Construct an invalid query.
Base class for range processors.
RangeProcessor * release()
Start reference counting this object.
virtual Xapian::Query operator()(const std::string &begin, const std::string &end)
Check for a valid range of this type.
RangeProcessor(const RangeProcessor &)
Don't allow copying.
void operator=(const RangeProcessor &)
Don't allow assignment.
const RangeProcessor * release() const
Start reference counting this object.
std::string str
The prefix (or suffix with RP_SUFFIX) string to look for.
RangeProcessor(Xapian::valueno slot_, const std::string &str_=std::string(), unsigned flags_=0)
Constructor.
Xapian::valueno slot
The value slot to process.
RangeProcessor()
Default constructor.
Simple implementation of Stopper class - this will suit most users.
std::set< std::string > stop_words
void add(const std::string &word)
Add a single stop word.
SimpleStopper()
Default constructor.
SimpleStopper(Iterator begin, Iterator end)
Initialise from a pair of iterators.
virtual bool operator()(const std::string &term) const
Is term a stop-word?
Class representing a stemming algorithm.
Abstract base class for stop-word decision functor.
Stopper(const Stopper &)
Don't allow copying.
virtual bool operator()(const std::string &term) const =0
Is term a stop-word?
const Stopper * release() const
Start reference counting this object.
Stopper()
Default constructor.
Stopper * release()
Start reference counting this object.
virtual ~Stopper()
Class has virtual methods, so provide a virtual destructor.
void operator=(const Stopper &)
Don't allow assignment.
StringValueRangeProcessor(Xapian::valueno slot_)
Constructor.
Xapian::valueno valno
The value slot to process.
bool prefix
Whether to look for str as a prefix or suffix.
std::string str
The prefix (or suffix if prefix==false) string to look for.
StringValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, bool prefix_=true)
Constructor.
Class for iterating over a list of terms.
Base class for value range processors.
ValueRangeProcessor(const ValueRangeProcessor &)
Don't allow copying.
const ValueRangeProcessor * release() const
Start reference counting this object.
ValueRangeProcessor()
Default constructor.
void operator=(const ValueRangeProcessor &)
Don't allow assignment.
virtual Xapian::valueno operator()(std::string &begin, std::string &end)=0
Check for a valid range of this type.
ValueRangeProcessor * release()
Start reference counting this object.
Define XAPIAN_DEPRECATED() and related macros.
#define XAPIAN_DEPRECATED_CLASS_EX
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
const valueno BAD_VALUENO
Reserved value to indicate "no valueno".
double sortable_unserialise(const std::string &serialised)
Convert a string encoded using sortable_serialise back to a floating point number.
std::string sortable_serialise(double value)
Convert a floating point number to a string, preserving sort order.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned valueno
The number for a value slot in a document.
size_t sortable_serialise_(double value, char *buf)
#define XAPIAN_DEPRECATED(X)
static Xapian::Stem stemmer
Class for iterating over a list of terms.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT