From 88c74453f5441a9553ee487b91f372bc15faef91 Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Thu, 22 Sep 2016 15:50:18 +0900 Subject: [PATCH] Fixed the code to work with tantivy's 1a08ca4f95b690c6d4ae3f737dd8ab41380dbb82 --- src/commands/bench.rs | 6 +++--- src/commands/new.rs | 6 +++--- src/commands/serve.rs | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/commands/bench.rs b/src/commands/bench.rs index 4e83367..387bcf9 100644 --- a/src/commands/bench.rs +++ b/src/commands/bench.rs @@ -69,10 +69,10 @@ fn run_bench(index_path: &Path, let query = query_parser.parse_query(&query_txt).unwrap(); let num_terms = query.num_terms(); let mut top_collector = TopCollector::with_limit(10); - let mut count_collector = CountCollector::new(); + let mut count_collector = CountCollector::default(); let timing; { - let mut collector = chain().add(&mut top_collector).add(&mut count_collector); + let mut collector = chain().push(&mut top_collector).push(&mut count_collector); timing = try!(query.search(&searcher, &mut collector).map_err(|e| format!("Failed while searching query {:?}.\n\n{:?}", query_txt, e))); } println!("{}\t{}\t{}\t{}", query_txt, num_terms, count_collector.count(), timing.total_time()); @@ -87,7 +87,7 @@ fn run_bench(index_path: &Path, let query = query_parser.parse_query(&query_txt).unwrap(); let mut top_collector = TopCollector::with_limit(10); try!(query.search(&searcher, &mut top_collector).map_err(|e| format!("Failed while retrieving document for query {:?}.\n{:?}", query, e))); - let mut timer = TimerTree::new(); + let mut timer = TimerTree::default(); { let _scoped_timer_ = timer.open("total"); for doc_address in top_collector.docs() { diff --git a/src/commands/new.rs b/src/commands/new.rs index cecf9e4..9dbdd8c 100644 --- a/src/commands/new.rs +++ b/src/commands/new.rs @@ -73,7 +73,7 @@ fn prompt_yn(msg: &str) -> bool { fn ask_add_field_text(field_name: &str, schema_builder: &mut SchemaBuilder) { - let mut text_options = TextOptions::new(); + let mut text_options = TextOptions::default(); if prompt_yn("Should the field be stored") { text_options = text_options.set_stored(); } @@ -105,7 +105,7 @@ fn ask_add_field_text(field_name: &str, schema_builder: &mut SchemaBuilder) { fn ask_add_field_u32(field_name: &str, schema_builder: &mut SchemaBuilder) { - let mut u32_options = U32Options::new(); + let mut u32_options = U32Options::default(); if prompt_yn("Should the field be stored") { u32_options = u32_options.set_stored(); } @@ -133,7 +133,7 @@ fn ask_add_field(schema_builder: &mut SchemaBuilder) { fn run_new(directory: PathBuf) -> tantivy::Result<()> { println!("\n{} ", Style::new().bold().fg(Green).paint("Creating new index")); println!("{} ", Style::new().bold().fg(Green).paint("Let's define it's schema!")); - let mut schema_builder = SchemaBuilder::new(); + let mut schema_builder = SchemaBuilder::default(); loop { ask_add_field(&mut schema_builder); if !prompt_yn("Add another field") { diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 0699ff4..2aa5e94 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -111,14 +111,14 @@ impl IndexServer { fn search(&self, q: String, num_hits: usize, explain: bool) -> tantivy::Result { let query = self.query_parser.parse_query(&q).unwrap(); let searcher = self.index.searcher(); - let mut count_collector = CountCollector::new(); + let mut count_collector = CountCollector::default(); let mut top_collector = TopCollector::with_limit(num_hits); - let mut timer_tree = TimerTree::new(); + let mut timer_tree = TimerTree::default(); { let _search_timer = timer_tree.open("search"); let mut chained_collector = collector::chain() - .add(&mut top_collector) - .add(&mut count_collector); + .push(&mut top_collector) + .push(&mut count_collector); try!(query.search(&searcher, &mut chained_collector)); } let hits: Vec = {