@@ -69,10 +69,10 @@ fn run_bench(index_path: &Path, | |||||
let query = query_parser.parse_query(&query_txt).unwrap(); | let query = query_parser.parse_query(&query_txt).unwrap(); | ||||
let num_terms = query.num_terms(); | let num_terms = query.num_terms(); | ||||
let mut top_collector = TopCollector::with_limit(10); | let mut top_collector = TopCollector::with_limit(10); | ||||
let mut count_collector = CountCollector::new(); | |||||
let mut count_collector = CountCollector::default(); | |||||
let timing; | 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))); | 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()); | 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 query = query_parser.parse_query(&query_txt).unwrap(); | ||||
let mut top_collector = TopCollector::with_limit(10); | 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))); | 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"); | let _scoped_timer_ = timer.open("total"); | ||||
for doc_address in top_collector.docs() { | for doc_address in top_collector.docs() { | ||||
@@ -73,7 +73,7 @@ fn prompt_yn(msg: &str) -> bool { | |||||
fn ask_add_field_text(field_name: &str, schema_builder: &mut SchemaBuilder) { | 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") { | if prompt_yn("Should the field be stored") { | ||||
text_options = text_options.set_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) { | 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") { | if prompt_yn("Should the field be stored") { | ||||
u32_options = u32_options.set_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<()> { | fn run_new(directory: PathBuf) -> tantivy::Result<()> { | ||||
println!("\n{} ", Style::new().bold().fg(Green).paint("Creating new index")); | println!("\n{} ", Style::new().bold().fg(Green).paint("Creating new index")); | ||||
println!("{} ", Style::new().bold().fg(Green).paint("Let's define it's schema!")); | 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 { | loop { | ||||
ask_add_field(&mut schema_builder); | ask_add_field(&mut schema_builder); | ||||
if !prompt_yn("Add another field") { | if !prompt_yn("Add another field") { | ||||
@@ -111,14 +111,14 @@ impl IndexServer { | |||||
fn search(&self, q: String, num_hits: usize, explain: bool) -> tantivy::Result<Serp> { | fn search(&self, q: String, num_hits: usize, explain: bool) -> tantivy::Result<Serp> { | ||||
let query = self.query_parser.parse_query(&q).unwrap(); | let query = self.query_parser.parse_query(&q).unwrap(); | ||||
let searcher = self.index.searcher(); | 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 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 _search_timer = timer_tree.open("search"); | ||||
let mut chained_collector = collector::chain() | 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)); | try!(query.search(&searcher, &mut chained_collector)); | ||||
} | } | ||||
let hits: Vec<Hit> = { | let hits: Vec<Hit> = { | ||||