Struct tique::QueryParser[][src]

pub struct QueryParser { /* fields omitted */ }
Expand description

Parse queries from arbitrary end-user input

Words and phrases are supported as usual. For a query like:

apple “peanut butter”

Every document that contains the word “apple” or the phrase “peanut butter” will be a candidate for collection.

You may make items required or prohibited:

-“deep fry” +bacon

Now documents must contain “bacon” and must not contain the phrase “deep fry”

And you can limit which fields are looked at by prefixing an item with the field name:

cake butter -ingredients:egg

Which ends up prohibiting documents with “egg” in the “ingredients” field from showing up.

Implementations

Create a QueryParser that knows about the given fields and queries them by default.

Errors

Will yield an error if any of fields is not known by the given index

Configure the importance of a field

By default, every field has a boost of None, which is equivalent to a boost of Some(1.0). Less than 1.0 means lower importance, greater means higher.

Change/disable how to query a specific field

The QueryParser uses the field name present in the index schema as the field name, so if you have a field named “body”, the parser knows to only look at that field when searching for body:potato.

You can use this to change how (or make it impossible) to address any field from a query.

Configure which fields are queried by default

When a query input doesn’t specify a field name explicitly, the parser uses these fields by default. So if you have a parser with default fields a and b, a query like “foo b:bar” ends up searching for “foo” in both fields, but “bar” only on b.

Parse arbitrary user input into a tantivy query

None may happen when the input is empty or the field analyzers end up emitting no tokens. Example: an analyzer that filters stop words would return None for a query like “the is at which”.

Parse a query, taking multiple fields with similar vocabularies into account.

Behaves like QueryParser::parse, but uses DisMaxQuery when searching over multiple fields.

The tiebreaker parameter governs the importance of appearing in more than one field and a small value like 0.1 or even 0 is a reasonable starting point.

Panics when tiebreaker is lower than zero or greater than one.

Refer to DisMaxQuery’s docs for more details.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.