Upgrade Tantivy to v0.12.0 (#771)

* Upgrade Tantivy to 0.12.0

* Follow Tantivy Tokenizer's new type definition

* Wrap tokenizers with TextAnalyzer to use filter methods

* Replace async IndexWriter::garbage_collect_files with sync functions

* Update Cargo.toml
This commit is contained in:
KITAITI Makoto
2020-05-20 20:31:45 +09:00
committed by GitHub
parent efb76a3c17
commit ef70cb93e6
4 changed files with 248 additions and 220 deletions
+5 -7
View File
@@ -1,5 +1,5 @@
use std::str::CharIndices;
use tantivy::tokenizer::{Token, TokenStream, Tokenizer};
use tantivy::tokenizer::{BoxTokenStream, Token, TokenStream, Tokenizer};
/// Tokenize the text by splitting on whitespaces. Pretty much a copy of Tantivy's SimpleTokenizer,
/// but not splitting on punctuation
@@ -12,15 +12,13 @@ pub struct WhitespaceTokenStream<'a> {
token: Token,
}
impl<'a> Tokenizer<'a> for WhitespaceTokenizer {
type TokenStreamImpl = WhitespaceTokenStream<'a>;
fn token_stream(&self, text: &'a str) -> Self::TokenStreamImpl {
WhitespaceTokenStream {
impl Tokenizer for WhitespaceTokenizer {
fn token_stream<'a>(&self, text: &'a str) -> BoxTokenStream<'a> {
BoxTokenStream::from(WhitespaceTokenStream {
text,
chars: text.char_indices(),
token: Token::default(),
}
})
}
}
impl<'a> WhitespaceTokenStream<'a> {