[−][src]Struct tique::QueryParser
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.
Methods
impl QueryParser
[src]
pub fn new(index: &Index, fields: Vec<Field>) -> Result<Self>
[src]
Create a QueryParser that knows about the given fields and queries them by default.
pub fn set_boost(&mut self, field: Field, boost: Option<f32>)
[src]
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.
pub fn set_name(&mut self, field: Field, name: Option<String>)
[src]
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.
pub fn set_default_fields(&mut self, fields: Vec<Field>)
[src]
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
.
pub fn parse(&self, input: &str) -> Option<Box<dyn Query>>
[src]
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".
pub fn parse_dixmax(
&self,
input: &str,
tiebreaker: f32
) -> Option<Box<dyn Query>>
[src]
&self,
input: &str,
tiebreaker: f32
) -> Option<Box<dyn Query>>
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
impl !RefUnwindSafe for QueryParser
impl Send for QueryParser
impl Sync for QueryParser
impl Unpin for QueryParser
impl !UnwindSafe for QueryParser
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Downcast for T where
T: Any,
T: Any,
fn into_any(self: Box<T>) -> Box<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> DowncastSync for T where
T: Send + Sync + Any,
T: Send + Sync + Any,
impl<T> Erased for T
impl<T> From<T> for T
[src]
impl<T> Fruit for T where
T: Send + Downcast,
[src]
T: Send + Downcast,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,