|
|
@@ -2,7 +2,6 @@ use tantivy::Index; |
|
|
|
use tantivy::schema::{Field, Schema}; |
|
|
|
use tantivy::query::QueryParser; |
|
|
|
use std::path::Path; |
|
|
|
use tantivy::TimerTree; |
|
|
|
use std::io::BufReader; |
|
|
|
use std::io::BufRead; |
|
|
|
use std::io; |
|
|
@@ -52,7 +51,7 @@ fn run_bench(index_path: &Path, |
|
|
|
println!("Query : {:?}", index_path); |
|
|
|
println!("-------------------------------\n\n\n"); |
|
|
|
|
|
|
|
let index = Index::open(index_path).map_err(|e| format!("Failed to open index.\n{:?}", e))?; |
|
|
|
let index = Index::open_in_dir(index_path).map_err(|e| format!("Failed to open index.\n{:?}", e))?; |
|
|
|
let searcher = index.searcher(); |
|
|
|
let default_search_fields: Vec<Field> = extract_search_fields(&index.schema()); |
|
|
|
let queries = read_query_file(query_filepath).map_err(|e| format!("Failed reading the query file: {}", e))?; |
|
|
@@ -66,13 +65,11 @@ fn run_bench(index_path: &Path, |
|
|
|
// let num_terms = query.num_terms(); |
|
|
|
let mut top_collector = TopCollector::with_limit(10); |
|
|
|
let mut count_collector = CountCollector::default(); |
|
|
|
let timing; |
|
|
|
{ |
|
|
|
let mut collector = chain().push(&mut top_collector).push(&mut count_collector); |
|
|
|
timing = query.search(&searcher, &mut collector) |
|
|
|
query.search(&searcher, &mut collector) |
|
|
|
.map_err(|e| format!("Failed while searching query {:?}.\n\n{:?}", query_txt, e))?; |
|
|
|
} |
|
|
|
println!("{}\t{}\t{}", query_txt, count_collector.count(), timing.total_time()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -85,6 +82,7 @@ fn run_bench(index_path: &Path, |
|
|
|
let mut top_collector = TopCollector::with_limit(10); |
|
|
|
query.search(&searcher, &mut top_collector) |
|
|
|
.map_err(|e| format!("Failed while retrieving document for query {:?}.\n{:?}", query, e))?; |
|
|
|
/* |
|
|
|
let mut timer = TimerTree::default(); |
|
|
|
{ |
|
|
|
let _scoped_timer_ = timer.open("total"); |
|
|
@@ -93,6 +91,7 @@ fn run_bench(index_path: &Path, |
|
|
|
} |
|
|
|
} |
|
|
|
println!("{}\t{}", query_txt, timer.total_time()); |
|
|
|
*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|