Browse Source

Fixed the code to work with tantivy's 1a08ca4f95

develop
Paul Masurel 8 years ago
parent
commit
88c74453f5
3 changed files with 10 additions and 10 deletions
  1. +3
    -3
      src/commands/bench.rs
  2. +3
    -3
      src/commands/new.rs
  3. +4
    -4
      src/commands/serve.rs

+ 3
- 3
src/commands/bench.rs View File

@@ -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() {


+ 3
- 3
src/commands/new.rs View File

@@ -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") {


+ 4
- 4
src/commands/serve.rs View File

@@ -111,14 +111,14 @@ impl IndexServer {
fn search(&self, q: String, num_hits: usize, explain: bool) -> tantivy::Result<Serp> {
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<Hit> = {


Loading…
Cancel
Save