22 #ifndef XAPIAN_INCLUDED_QUERYPARSER_H
23 #define XAPIAN_INCLUDED_QUERYPARSER_H
25 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
26 # error Never use <xapian/queryparser.h> directly; include <xapian.h> instead.
36 #include <string_view>
37 #include <unordered_set>
71 virtual std::string get_description()
const;
81 opt_intrusive_base::release();
93 opt_intrusive_base::release();
119 template<
class Iterator>
123 void add(
const std::string & word) { stop_words.insert(word); }
126 return stop_words.find(
term) != stop_words.end();
129 virtual std::string get_description()
const;
193 std::string_view str_ = {},
195 : slot(slot_),
str(str_), flags(flags_) { }
198 virtual ~RangeProcessor();
205 Xapian::Query check_range(
const std::string& b,
const std::string& e);
223 operator()(
const std::string &begin,
const std::string &end);
233 opt_intrusive_base::release();
245 opt_intrusive_base::release();
273 int epoch_year_ = 1970)
275 epoch_year(epoch_year_) { }
313 unsigned flags_ = 0,
int epoch_year_ = 1970)
315 epoch_year(epoch_year_) { }
351 Xapian::Query operator()(
const std::string& begin,
const std::string& end);
402 std::string_view str_ = {},
418 Xapian::Query operator()(
const std::string& begin,
const std::string& end);
447 std::string_view str_ = {})
462 Xapian::Query operator()(
const std::string& begin,
const std::string& end);
498 opt_intrusive_base::release();
510 opt_intrusive_base::release();
532 FLAG_BOOLEAN_ANY_CASE = 8,
592 FLAG_SPELLING_CORRECTION = 128,
604 FLAG_AUTO_SYNONYMS = 512,
611 FLAG_AUTO_MULTIWORD_SYNONYMS = 1024,
644 FLAG_CJK_NGRAM = FLAG_NGRAMS,
658 FLAG_WORD_BREAKS = 4096,
673 FLAG_WILDCARD_MULTI = 8192,
688 FLAG_WILDCARD_SINGLE = 16384,
699 FLAG_WILDCARD_GLOB = FLAG_WILDCARD_MULTI | FLAG_WILDCARD_SINGLE,
726 FLAG_ACCUMULATE = 65536,
737 FLAG_NO_POSITIONS = 0x20000,
775 FLAG_NO_PROPER_NOUN_HEURISTIC = 0x40000,
784 FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE
789 STEM_NONE, STEM_SOME,
STEM_ALL, STEM_ALL_Z, STEM_SOME_FULL_POS
796 typedef enum { STOP_NONE,
STOP_ALL, STOP_STEMMED } stop_strategy;
860 void set_stopper(
const Stopper *stop = NULL);
901 void set_default_op(
Query::op default_op);
912 void set_database(
const Database &db);
943 unsigned flags = FLAG_WILDCARD |
970 void set_min_wildcard_prefix(
unsigned min_prefix_len,
971 unsigned flags = FLAG_WILDCARD|FLAG_PARTIAL);
996 Query parse_query(std::string_view query_string,
997 unsigned flags = FLAG_DEFAULT,
998 std::string_view default_prefix = {});
1044 void add_prefix(std::string_view field, std::string_view prefix);
1109 void add_boolean_prefix(std::string_view field, std::string_view prefix,
1110 const std::string*
grouping = NULL);
1137 add_boolean_prefix(field, prefix);
1139 std::string empty_grouping;
1140 add_boolean_prefix(field, prefix, &empty_grouping);
1146 void add_boolean_prefix(std::string_view field,
1148 const std::string*
grouping = NULL);
1159 add_boolean_prefix(field, proc);
1161 std::string empty_grouping;
1162 add_boolean_prefix(field, proc, &empty_grouping);
1184 const std::string*
grouping = NULL);
1193 std::string get_corrected_query_string()
const;
1196 std::string get_description()
const;
Compiler attribute macros.
An indexed database of documents.
DateRangeProcessor(Xapian::valueno slot_, unsigned flags_=0, int epoch_year_=1970)
Constructor.
DateRangeProcessor(Xapian::valueno slot_, std::string_view str_, unsigned flags_=0, 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.
Base class for objects managed by opt_intrusive_ptr.
NumberRangeProcessor(Xapian::valueno slot_, std::string_view str_={}, unsigned flags_=0)
Constructor.
Build a Xapian::Query object from a user query string.
void add_boolean_prefix(std::string_view field, std::string_view prefix, bool exclusive)
Add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in t...
TermIterator unstem_end(std::string_view) const noexcept
End iterator over unstemmed forms of the given stemmed query term.
QueryParser & operator=(QueryParser &&o)
Move assignment operator.
QueryParser(QueryParser &&o)
Move constructor.
void add_boolean_prefix(std::string_view field, Xapian::FieldProcessor *proc, bool exclusive)
Register a FieldProcessor for a boolean prefix.
TermIterator stoplist_end() const noexcept
End iterator over terms omitted from the query as stopwords.
QueryParser & operator=(const QueryParser &o)
Assignment.
stop_strategy
Stopper strategies, for use with set_stopper_strategy().
QueryParser(const QueryParser &o)
Copy constructor.
stem_strategy
Stemming strategies, for use with set_stemming_strategy().
Class representing a query.
@ WILDCARD_LIMIT_ERROR
Throw an error if OP_WILDCARD exceeds its expansion limit.
Base class for range processors.
RangeProcessor * release()
Start reference counting this object.
RangeProcessor(const RangeProcessor &)
Don't allow copying.
RangeProcessor(Xapian::valueno slot_, std::string_view str_={}, unsigned flags_=0)
Constructor.
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.
Xapian::valueno slot
The value slot to process.
RangeProcessor()
Default constructor.
Simple implementation of Stopper class - this will suit most users.
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.
std::unordered_set< std::string > stop_words
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.
virtual bool operator()(const std::string &term) const =0
Is term a stop-word?
const Stopper * release() const
Start reference counting this object.
void operator=(const Stopper &)=delete
Don't allow assignment.
Stopper(const Stopper &)=delete
Don't allow copying.
Stopper()
Default constructor.
Stopper * release()
Start reference counting this object.
virtual ~Stopper()
Class has virtual methods, so provide a virtual destructor.
Class for iterating over a list of terms.
Handle a byte unit range.
UnitRangeProcessor(Xapian::valueno slot_, std::string_view str_={})
Constructor.
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".
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.
size_t sortable_serialise_(double value, char *buf) noexcept
double sortable_unserialise(std::string_view serialised) noexcept
Convert a string encoded using sortable_serialise back to a floating point number.
unsigned valueno
The number for a value slot in a document.
static Xapian::Stem stemmer
Class for iterating over a list of terms.
Define XAPIAN_VISIBILITY_* macros.
#define XAPIAN_VISIBILITY_DEFAULT