41 return "Xapian::Stopper subclass";
47 string desc(
"Xapian::SimpleStopper(");
48 for (
auto i = stop_words.begin(); i != stop_words.end(); ++i) {
49 if (i != stop_words.begin()) desc +=
' ';
83 internal->stem_action = strategy;
89 internal->stopper = stopper;
95 internal->stop_mode = strategy;
101 switch (default_op) {
113 "QueryParser::set_default_op() only accepts "
128 internal->default_op = default_op;
134 return internal->default_op;
148 internal->max_wildcard_expansion = max_expansion;
149 internal->max_wildcard_type = max_type;
152 internal->max_partial_expansion = max_expansion;
153 internal->max_partial_type = max_type;
156 internal->max_fuzzy_expansion = max_expansion;
157 internal->max_fuzzy_type = max_type;
166 internal->min_wildcard_prefix_len = min_prefix_len;
169 internal->min_partial_prefix_len = min_prefix_len;
175 string_view default_prefix)
178 internal->stoplist.clear();
179 internal->unstem.clear();
181 internal->errmsg = NULL;
183 if (query_string.empty())
return Query();
185 Query result =
internal->parse_query(query_string, flags, default_prefix);
192 result =
internal->parse_query(query_string, flags, default_prefix);
202 internal->add_prefix(field, prefix);
208 internal->add_prefix(field, proc);
215 internal->add_boolean_prefix(field, prefix,
grouping);
223 internal->add_boolean_prefix(field, proc,
grouping);
229 const list<string> & sl =
internal->stoplist;
236 using unstem_type = multimap<string, string, std::less<>>;
237 struct range_adaptor :
public unstem_type::iterator {
238 range_adaptor(unstem_type::iterator i) : unstem_type::iterator(i) {}
239 const string &
operator*()
const {
return (*this)->second; }
241 auto range =
internal->unstem.equal_range(
term);
243 range_adaptor(range.second)));
256 return internal->corrected_query;
263 return "Xapian::QueryParser()";
This class stores a list of terms.
An indexed database of documents.
Base class for field processors.
virtual ~FieldProcessor()
Destructor.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Indicates a query string can't be parsed.
Build a Xapian::Query object from a user query string.
void set_database(const Database &db)
Specify the database being searched.
void add_rangeprocessor(Xapian::RangeProcessor *range_proc, const std::string *grouping=NULL)
Register a RangeProcessor.
void set_stemmer(const Xapian::Stem &stemmer)
Set the stemmer.
QueryParser()
Default constructor.
void set_min_wildcard_prefix(unsigned min_prefix_len, unsigned flags=FLAG_WILDCARD|FLAG_PARTIAL)
Specify minimum length for fixed initial portion in wildcard patterns.
~QueryParser()
Destructor.
void set_stemming_strategy(stem_strategy strategy)
Set the stemming strategy.
void add_boolean_prefix(std::string_view field, std::string_view prefix, const std::string *grouping=NULL)
Add a boolean term prefix allowing the user to restrict a search with a boolean filter specified in t...
std::string get_description() const
Return a string describing this object.
Xapian::Internal::intrusive_ptr_nonnull< Internal > internal
Query::op get_default_op() const
Get the current default operator.
void set_max_expansion(Xapian::termcount max_expansion, int max_type=Xapian::Query::WILDCARD_LIMIT_ERROR, unsigned flags=FLAG_WILDCARD|FLAG_PARTIAL|FLAG_FUZZY)
Specify the maximum expansion of a wildcard and/or partial and/or fuzzy term.
void set_stopper_strategy(stop_strategy strategy)
Set the stopper strategy.
void add_prefix(std::string_view field, std::string_view prefix)
Add a free-text field term prefix.
TermIterator unstem_begin(std::string_view term) const
Begin iterator over unstemmed forms of the given stemmed query term.
QueryParser & operator=(const QueryParser &o)
Assignment.
Query parse_query(std::string_view query_string, unsigned flags=FLAG_DEFAULT, std::string_view default_prefix={})
Parse a query.
void set_default_op(Query::op default_op)
Set the default operator.
void set_stopper(const Stopper *stop=NULL)
Set the stopper.
std::string get_corrected_query_string() const
Get the spelling-corrected query string.
stop_strategy
Stopper strategies, for use with set_stopper_strategy().
stem_strategy
Stemming strategies, for use with set_stemming_strategy().
@ FLAG_NGRAMS
Generate n-grams for scripts without explicit word breaks.
@ FLAG_ACCUMULATE
Accumulate unstem and stoplist results.
@ FLAG_NO_PROPER_NOUN_HEURISTIC
Turn off special handling of capitalised words.
@ FLAG_FUZZY
Support fuzzy matching.
@ FLAG_WORD_BREAKS
Find word breaks for text in scripts without explicit word breaks.
@ FLAG_WILDCARD
Support wildcards.
@ FLAG_NO_POSITIONS
Produce a query which doesn't use positional information.
@ FLAG_PARTIAL
Enable partial matching.
TermIterator stoplist_begin() const
Begin iterator over terms omitted from the query as stopwords.
Class representing a query.
@ OP_MAX
Pick the maximum weight of any subquery.
@ OP_NEAR
Match only documents where all subqueries match near each other.
@ OP_ELITE_SET
Pick the best N subqueries and combine with OP_OR.
@ OP_AND
Match only documents which all subqueries match.
@ OP_OR
Match documents which at least one subquery matches.
@ OP_PHRASE
Match only documents where all subqueries match near and in order.
@ OP_SYNONYM
Match like OP_OR but weighting as if a single term.
Base class for range processors.
virtual ~RangeProcessor()
Destructor.
virtual std::string get_description() const
Return a string describing this object.
Class representing a stemming algorithm.
Abstract base class for stop-word decision functor.
virtual std::string get_description() const
Return a string describing this object.
Class for iterating over a list of terms.
Hierarchy of classes which Xapian can throw as exceptions.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
const Query operator*(double factor, const Query &q)
Scale a Xapian::Query object using OP_SCALE_WEIGHT.
parsing a user query string to build a Xapian::Query object
The non-lemon-generated parts of the QueryParser class.
static Xapian::Stem stemmer
Class for iterating over a list of terms.
A vector-like container of terms which can be iterated.