caio.co/de/cantine

Upgrade to tantivy 0.12

Id
42c1d5ff3fc365bc549a7dc23be850d6c54733a6
Author
Caio
Commit time
2020-02-19T15:05:58+01:00

Modified cantine/Cargo.toml

@@ -23,7 +23,7
memmap = "0.7"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
-tantivy = "0.11"
+tantivy = "0.12"
uuid = { version = "0.8", features = ["serde"] }
zerocopy = "0.2"

Modified cantine_derive/Cargo.toml

@@ -8,7 +8,7
[dependencies]
cantine_derive_internal = { path = "./internal" }
serde = { version = "1.0" }
-tantivy = "0.11"
+tantivy = "0.12"

[dev-dependencies]
serde = { version = "1.0", features = ["derive"] }

Modified tique/Cargo.toml

@@ -17,5 +17,5
unstable = ["nom"]

[dependencies]
-tantivy = "0.11"
+tantivy = "0.12"
nom = { version = "5", optional = true }

Modified tique/src/lib.rs

@@ -33,7 +33,7
//! # let index = Index::create_in_ram(builder.build());
//! let topterms = TopTerms::new(&index, vec![body, title])?;
//! let keywords = topterms.extract(5, "the quick fox jumps over the lazy dog");
-//! # Ok::<(), tantivy::Error>(())
+//! # Ok::<(), tantivy::TantivyError>(())
//!```

pub mod conditional_collector;

Modified tique/src/topterms.rs

@@ -40,7 +40,7
//! # let searcher = reader.searcher();
//! let nearest_neighbors =
//! searcher.search(&keywords.into_query(), &TopDocs::with_limit(10))?;
-//! # Ok::<(), tantivy::Error>(())
+//! # Ok::<(), tantivy::TantivyError>(())
//!```
//!
//! ## Tuning the Keywords Extration
@@ -69,7 +69,7
//! term.text().chars().count() > 4 && doc_freq >= 10
//! }
//! );
-//! # Ok::<(), tantivy::Error>(())
+//! # Ok::<(), tantivy::TantivyError>(())
//!```
//!
use std::{collections::HashMap, str};
@@ -77,7 +77,7
use tantivy::{
query::BooleanQuery,
schema::{Field, FieldType, IndexRecordOption, Schema},
- tokenizer::BoxedTokenizer,
+ tokenizer::TextAnalyzer,
DocAddress, DocSet, Index, IndexReader, Postings, Result, Searcher, SkipResult, Term,
};

@@ -92,7 +92,7
/// TopTerms extracts the most relevant Keywords from your index
pub struct TopTerms {
reader: IndexReader,
- field_tokenizers: Vec<(Field, BoxedTokenizer)>,
+ field_tokenizers: Vec<(Field, TextAnalyzer)>,
}

/// Allows tuning the algorithm to pick the top keywords
@@ -248,7 +248,7
}
}

-fn termfreq(input: &str, field: Field, tokenizer: &BoxedTokenizer) -> HashMap<Term, u32> {
+fn termfreq(input: &str, field: Field, tokenizer: &TextAnalyzer) -> HashMap<Term, u32> {
let mut termfreq = HashMap::new();

let mut stream = tokenizer.token_stream(&input);

Modified tique/src/queryparser/interpreter.rs

@@ -1,21 +1,21
use super::parser::{parse_query, Token};

use tantivy::{
self,
query::{AllQuery, BooleanQuery, Occur, PhraseQuery, Query, TermQuery},
schema::{Field, IndexRecordOption},
- tokenizer::BoxedTokenizer,
+ tokenizer::TextAnalyzer,
Result, Term,
};

pub struct QueryParser {
field: Field,
- tokenizer: BoxedTokenizer,
+ tokenizer: TextAnalyzer,
occur: Occur,
}

impl QueryParser {
- pub fn new(field: Field, tokenizer: BoxedTokenizer, match_all: bool) -> QueryParser {
+ pub fn new(field: Field, tokenizer: TextAnalyzer, match_all: bool) -> QueryParser {
QueryParser {
field,
tokenizer,