From c0cb01a919c6237c3195b1473e9fe88a2b398cdd Mon Sep 17 00:00:00 2001 From: Paul Masurel Date: Fri, 4 Nov 2016 16:58:32 +0900 Subject: [PATCH] NOBUG updating tantivy --- src/commands/bench.rs | 5 ++--- src/commands/new.rs | 3 ++- src/commands/serve.rs | 17 +++-------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/commands/bench.rs b/src/commands/bench.rs index 387bcf9..921700b 100644 --- a/src/commands/bench.rs +++ b/src/commands/bench.rs @@ -1,7 +1,6 @@ use tantivy::Index; use tantivy::schema::{Field, Schema}; use tantivy::query::QueryParser; -use tantivy::query::Query; use std::path::Path; use tantivy::TimerTree; use std::io::BufReader; @@ -67,7 +66,7 @@ fn run_bench(index_path: &Path, for _ in 0..num_repeat { for query_txt in &queries { 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 count_collector = CountCollector::default(); let timing; @@ -75,7 +74,7 @@ fn run_bench(index_path: &Path, 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()); + println!("{}\t{}\t{}", query_txt, count_collector.count(), timing.total_time()); } } diff --git a/src/commands/new.rs b/src/commands/new.rs index 9dbdd8c..edb1329 100644 --- a/src/commands/new.rs +++ b/src/commands/new.rs @@ -144,6 +144,7 @@ fn run_new(directory: PathBuf) -> tantivy::Result<()> { let schema_json = format!("{}", json::as_pretty_json(&schema)); println!("\n{}\n", Style::new().fg(Green).paint(schema_json)); let mut index = try!(Index::create(&directory, schema)); - index.save_metas() + // index.save_metas() + Ok(()) } diff --git a/src/commands/serve.rs b/src/commands/serve.rs index 2aa5e94..d799763 100644 --- a/src/commands/serve.rs +++ b/src/commands/serve.rs @@ -35,8 +35,6 @@ use tantivy::collector::CountCollector; use tantivy::collector::TopCollector; use tantivy::Document; use tantivy::Index; -use tantivy::query::Explanation; -use tantivy::query::Query; use tantivy::query::QueryParser; use tantivy::schema::Field; use tantivy::schema::FieldType; @@ -65,7 +63,6 @@ struct Serp { #[derive(RustcEncodable)] struct Hit { doc: NamedFieldDocument, - explain: Option, } struct IndexServer { @@ -101,10 +98,9 @@ impl IndexServer { } } - fn create_hit(&self, doc: &Document, explain: Option) -> Hit { + fn create_hit(&self, doc: &Document) -> Hit { Hit { - doc: self.schema.to_named_doc(&doc), - explain: explain, + doc: self.schema.to_named_doc(&doc) } } @@ -127,14 +123,7 @@ impl IndexServer { .iter() .map(|doc_address| { let doc: Document = searcher.doc(doc_address).unwrap(); - let explanation; - if explain { - explanation = Some(query.explain(&searcher, doc_address).unwrap()); - } - else { - explanation = None; - } - self.create_hit(&doc, explanation) + self.create_hit(&doc) }) .collect() };