pub struct LengthTokenFilter { /* private fields */ }
Available on crate feature
commons
only.Expand description
This TokenFilter filters tokens that don’t match a min or a max length (inclusive).
use tantivy_analysis_contrib::commons::LengthTokenFilter;
let length_token_filter = LengthTokenFilter::new(Some(4), Some(10));
§Example
In this example, tokens There
, 1
and token
are filtered out because they are too short or
too long.
use tantivy::tokenizer::{WhitespaceTokenizer, TextAnalyzer, Token};
use tantivy_analysis_contrib::commons::LengthTokenFilter;
let mut tmp = TextAnalyzer::builder(WhitespaceTokenizer::default())
.filter(LengthTokenFilter::new(Some(2), Some(4)))
.build();
let mut token_stream = tmp.token_stream("There is 1 token");
let token = token_stream.next().expect("A token should be present.");
assert_eq!(token.text, "is".to_string());
assert_eq!(None, token_stream.next());
Implementations§
Trait Implementations§
source§impl Clone for LengthTokenFilter
impl Clone for LengthTokenFilter
source§fn clone(&self) -> LengthTokenFilter
fn clone(&self) -> LengthTokenFilter
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for LengthTokenFilter
impl Debug for LengthTokenFilter
source§impl TokenFilter for LengthTokenFilter
impl TokenFilter for LengthTokenFilter
impl Copy for LengthTokenFilter
Auto Trait Implementations§
impl Freeze for LengthTokenFilter
impl RefUnwindSafe for LengthTokenFilter
impl Send for LengthTokenFilter
impl Sync for LengthTokenFilter
impl Unpin for LengthTokenFilter
impl UnwindSafe for LengthTokenFilter
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more