#[repr(i32)]
pub enum QueryParserFeatureFlag {
Show 20 variants FLAG_BOOLEAN, FLAG_PHRASE, FLAG_LOVEHATE, FLAG_BOOLEAN_ANY_CASE, FLAG_WILDCARD, FLAG_PURE_NOT, FLAG_PARTIAL, FLAG_SPELLING_CORRECTION, FLAG_SYNONYM, FLAG_AUTO_SYNONYMS, FLAG_AUTO_MULTIWORD_SYNONYMS, FLAG_NGRAMS, FLAG_WORD_BREAKS, FLAG_WILDCARD_MULTI, FLAG_WILDCARD_SINGLE, FLAG_WILDCARD_GLOB, FLAG_FUZZY, FLAG_ACCUMULATE, FLAG_NO_POSITIONS, FLAG_DEFAULT,
}
Expand description

QueryParser::feature_flag

Variants§

§

FLAG_BOOLEAN

Support AND, OR, etc and bracketed subexpressions.

§

FLAG_PHRASE

Support quoted phrases.

§

FLAG_LOVEHATE

Support + and -.

§

FLAG_BOOLEAN_ANY_CASE

Support AND, OR, etc even if they aren’t in ALLCAPS.

§

FLAG_WILDCARD

Support wildcards.

At present only right truncation (e.g. Xap*) is supported.

Currently you can’t use wildcards with boolean filter prefixes, or in a phrase (either an explicitly quoted one, or one implicitly generated by hyphens or other punctuation).

In Xapian 1.2.x, you needed to tell the QueryParser object which database to expand wildcards from by calling set_database(). In Xapian 1.3.3, OP_WILDCARD was added and wildcards are now expanded when Enquire::get_mset() is called, with the expansion using the database being searched.

§

FLAG_PURE_NOT

Allow queries such as ‘NOT apples’.

These require the use of a list of all documents in the database which is potentially expensive, so this feature isn’t enabled by default.

§

FLAG_PARTIAL

Enable partial matching.

Partial matching causes the parser to treat the query as a “partially entered” search. This will automatically treat the final word as a wildcarded match, unless it is followed by whitespace, to produce more stable results from interactive searches.

Currently FLAG_PARTIAL doesn’t do anything if the final word in the query has a boolean filter prefix, or if it is in a phrase (either an explicitly quoted one, or one implicitly generated by hyphens or other punctuation). It also doesn’t do anything if if the final word is part of a value range.

In Xapian 1.2.x, you needed to tell the QueryParser object which database to expand wildcards from by calling set_database(). In Xapian 1.3.3, OP_WILDCARD was added and wildcards are now expanded when Enquire::get_mset() is called, with the expansion using the database being searched.

§

FLAG_SPELLING_CORRECTION

Enable spelling correction.

For each word in the query which doesn’t exist as a term in the database, Database::get_spelling_suggestion() will be called and if a suggestion is returned, a corrected version of the query string will be built up which can be read using QueryParser::get_corrected_query_string(). The query returned is based on the uncorrected query string however - if you want a parsed query based on the corrected query string, you must call QueryParser::parse_query() again.

NB: You must also call set_database() for this to work.

§

FLAG_SYNONYM

Enable synonym operator ‘~’.

NB: You must also call set_database() for this to work.

§

FLAG_AUTO_SYNONYMS

Enable automatic use of synonyms for single terms.

NB: You must also call set_database() for this to work.

§

FLAG_AUTO_MULTIWORD_SYNONYMS

Enable automatic use of synonyms for single terms and groups of terms.

NB: You must also call set_database() for this to work.

§

FLAG_NGRAMS

Generate n-grams for scripts without explicit word breaks.

Spans of characters in such scripts are split into unigrams and bigrams, with the unigrams carrying positional information. Text in other scripts is split into words as normal.

The TermGenerator::FLAG_NGRAMS flag needs to have been used at index time.

This mode can also be enabled in 1.2.8 and later by setting environment variable XAPIAN_CJK_NGRAM to a non-empty value (but doing so was deprecated in 1.4.11).

In 1.4.x this feature was specific to CJK (Chinese, Japanese and Korean), but in 1.5.0 it’s been extended to other languages. To reflect this change the new and preferred name is FLAG_NGRAMS, which was added as an alias for forward compatibility in Xapian 1.4.23. Use FLAG_CJK_NGRAM instead if you aim to support Xapian < 1.4.23.

@since Added in Xapian 1.4.23.

§

FLAG_WORD_BREAKS

Find word breaks for text in scripts without explicit word breaks.

With this option enabled, spans of text written in such scripts are split into words using ICU (which uses heuristics and/or dictionaries to do so). Text in other scripts is split into words as normal.

The TermGenerator::FLAG_WORD_BREAKS flag needs to have been used at index time.

@since Added in Xapian 1.5.0.

§

FLAG_WILDCARD_MULTI

Support extended wildcard ‘*’.

This flag enables support for wildcard ‘*’ matching zero or more characters, which may be used anywhere in a word.

Such wildcards can be relatively expensive to expand and to match so benchmark your system carefully if you have a lot of documents and/or a high search load.

FLAG_WILDCARD is ignored if this flag is specified.

@since Added in Xapian 1.5.0.

§

FLAG_WILDCARD_SINGLE

Support extended wildcard ‘?’.

This flag enables support for wildcard ‘?’ matching exactly one character, which may be use anywhere in a word.

Such wildcards can be relatively expensive to expand and to match so benchmark your system carefully if you have a lot of documents and/or a high search load.

FLAG_WILDCARD is ignored if this flag is specified.

@since Added in Xapian 1.5.0.

§

FLAG_WILDCARD_GLOB

Enable glob-style wildcarding.

This enables all supported glob-style wildcard pattern flags

  • currently that’s FLAG_WILDCARD_MULTI and FLAG_WILDCARD_SINGLE.

FLAG_WILDCARD is ignored if this flag is specified.

@since Added in Xapian 1.5.0.

§

FLAG_FUZZY

Support fuzzy matching.

E.g. “unserten~3” would expand to “uncertain” (and likely other terms).

foo~ uses edit distance of 2 since~0.2 uses edit distance of length(“since”) * 0.2 = 5 * 0.2 = 1

@since Added in Xapian 1.5.0.

§

FLAG_ACCUMULATE

Accumulate unstem and stoplist results.

By default, the unstem and stoplist data is reset by a call to parse_query(), which makes sense if you use the same QueryParser object to parse a series of independent queries.

If you’re using the same QueryParser object to parse several fields on the same query form, you may want to have the unstem and stoplist data combined for all of them, in which case you can use this flag to prevent this data from being reset.

@since Added in Xapian 1.4.18.

§

FLAG_NO_POSITIONS

Produce a query which doesn’t use positional information.

With this flag enabled, no positional information will be used and any query operations which would use it are replaced by the nearest equivalent which doesn’t (so phrase searches, NEAR and ADJ will result in OP_AND).

@since Added in Xapian 1.4.19.

§

FLAG_DEFAULT

The default flags.

Used if you don’t explicitly pass any to @a parse_query(). The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE.

@since Added in Xapian 1.0.11.

Trait Implementations§

source§

impl Debug for QueryParserFeatureFlag

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.