Skip to content

Commit

Permalink
[Misc] Upgrade Tantivy to 0.21.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
azasypkin committed Sep 2, 2023
1 parent 6470750 commit 2a5c833
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 70 deletions.
88 changes: 28 additions & 60 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ serde_json = "1.0.105"
serde_repr = "0.1.16"
serde_with = "3.3.0"
sqlx = "0.7.1"
tantivy = "0.20.2"
tantivy = "0.21.0"
time = "0.3.28"
tlsh2 = "0.3.0"
tokio-cron-scheduler = "0.9.4"
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn process_command(version: &str, matches: ArgMatches) -> Result<(), anyhow::Err
Url::parse(url)
.with_context(|| "Cannot parse Web Scraper URL parameter.".to_string())
})?,
search_index_version: 2,
search_index_version: 3,
},
jobs: SchedulerJobsConfig {
resources_trackers_schedule: matches
Expand Down Expand Up @@ -412,7 +412,7 @@ mod tests {
}),
components: ComponentsConfig {
web_scraper_url: Url::parse("http://localhost:7272")?,
search_index_version: 2,
search_index_version: 3,
},
jobs: SchedulerJobsConfig {
resources_trackers_schedule: Schedule::try_from("0 * 0 * * * *")?,
Expand Down
14 changes: 7 additions & 7 deletions src/search/search_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ impl SearchIndex {
let (schema_fields, schema) = SearchIndexSchemaFields::build();
let index = initializer(schema)?;

let ids_tokenizer = TextAnalyzer::builder(RawTokenizer::default())
.filter(LowerCaser)
.build();

let tokenizers = index.tokenizers();
tokenizers.register("ngram2_10", NgramTokenizer::prefix_only(2, 10));
tokenizers.register("ngram2_10", NgramTokenizer::prefix_only(2, 10)?);
tokenizers.register("ids", ids_tokenizer.clone());

let tokenizers = index.fast_field_tokenizer();
tokenizers.register(
"ids",
TextAnalyzer::builder(RawTokenizer::default())
.filter(LowerCaser)
.build(),
);
tokenizers.register("ids", ids_tokenizer);

let index_reader = index
.reader_builder()
Expand Down

0 comments on commit 2a5c833

Please sign in to comment.