@@ -50,7 +50,7 @@ fn run_index(directory: PathBuf, | |||||
} | } | ||||
}); | }); | ||||
let num_threads_to_parse_json = cmp::max(1, num_threads / 2); | |||||
let num_threads_to_parse_json = cmp::max(1, num_threads / 4); | |||||
info!("Using {} threads to parse json", num_threads_to_parse_json); | info!("Using {} threads to parse json", num_threads_to_parse_json); | ||||
for _ in 0..num_threads_to_parse_json { | for _ in 0..num_threads_to_parse_json { | ||||
let schema_clone = schema.clone(); | let schema_clone = schema.clone(); | ||||
@@ -84,13 +84,25 @@ fn run_index(directory: PathBuf, | |||||
index_writer.set_merge_policy(Box::new(NoMergePolicy)); | index_writer.set_merge_policy(Box::new(NoMergePolicy)); | ||||
} | } | ||||
let start_overall = PreciseTime::now(); | |||||
let index_result = index_documents(&mut index_writer, doc_receiver); | let index_result = index_documents(&mut index_writer, doc_receiver); | ||||
{ | |||||
let duration = start_overall.to(PreciseTime::now()); | |||||
info!("Indexing the documents took {} s", duration.num_seconds()); | |||||
} | |||||
match index_result { | match index_result { | ||||
Ok(docstamp) => { | Ok(docstamp) => { | ||||
println!("Commit succeed, docstamp at {}", docstamp); | println!("Commit succeed, docstamp at {}", docstamp); | ||||
println!("Waiting for merging threads"); | println!("Waiting for merging threads"); | ||||
index_writer.wait_merging_threads()?; | index_writer.wait_merging_threads()?; | ||||
println!("Terminated successfully!"); | println!("Terminated successfully!"); | ||||
{ | |||||
let duration = start_overall.to(PreciseTime::now()); | |||||
info!("Indexing the documents took {} overall (indexing + merge)", duration.num_seconds()); | |||||
} | |||||
Ok(()) | Ok(()) | ||||
} | } | ||||
Err(e) => { | Err(e) => { | ||||
@@ -1,13 +1,13 @@ | |||||
mod index; | mod index; | ||||
// mod serve; | |||||
// mod new; | |||||
// mod bench; | |||||
// mod merge; | |||||
// mod search; | |||||
mod serve; | |||||
mod new; | |||||
mod bench; | |||||
mod merge; | |||||
mod search; | |||||
// pub use self::new::run_new_cli; | |||||
pub use self::new::run_new_cli; | |||||
pub use self::index::run_index_cli; | pub use self::index::run_index_cli; | ||||
// pub use self::serve::run_serve_cli; | |||||
// pub use self::bench::run_bench_cli; | |||||
// pub use self::merge::run_merge_cli; | |||||
// pub use self::search::run_search_cli; | |||||
pub use self::serve::run_serve_cli; | |||||
pub use self::search::run_search_cli; | |||||
pub use self::bench::run_bench_cli; | |||||
pub use self::merge::run_merge_cli; |
@@ -12,9 +12,8 @@ use tantivy::schema::FieldType; | |||||
pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> { | pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> { | ||||
let index_directory = PathBuf::from(matches.value_of("index").unwrap()); | let index_directory = PathBuf::from(matches.value_of("index").unwrap()); | ||||
let query = matches.value_of("query").unwrap(); | let query = matches.value_of("query").unwrap(); | ||||
loop { | |||||
run_search(&index_directory, &query).map_err(|e| format!("{:?}", e)) | |||||
} | |||||
run_search(&index_directory, &query) | |||||
.map_err(|e| format!("{:?}", e)) | |||||
} | } | ||||
fn run_search(directory: &Path, query: &str) -> tantivy::Result<()> { | fn run_search(directory: &Path, query: &str) -> tantivy::Result<()> { | ||||
@@ -22,6 +22,7 @@ extern crate byteorder; | |||||
#[macro_use] | #[macro_use] | ||||
extern crate serde_derive; | extern crate serde_derive; | ||||
use clap::{AppSettings, Arg, App, SubCommand}; | use clap::{AppSettings, Arg, App, SubCommand}; | ||||
mod commands; | mod commands; | ||||
use self::commands::*; | use self::commands::*; | ||||
@@ -128,12 +129,12 @@ fn main() { | |||||
let (subcommand, some_options) = cli_options.subcommand(); | let (subcommand, some_options) = cli_options.subcommand(); | ||||
let options = some_options.unwrap(); | let options = some_options.unwrap(); | ||||
let run_cli = match subcommand { | let run_cli = match subcommand { | ||||
// "new" => run_new_cli, | |||||
"new" => run_new_cli, | |||||
"index" => run_index_cli, | "index" => run_index_cli, | ||||
// "serve" => run_serve_cli, | |||||
// "search" => run_search_cli, | |||||
// "merge" => run_merge_cli, | |||||
// "bench" => run_bench_cli, | |||||
"serve" => run_serve_cli, | |||||
"search" => run_search_cli, | |||||
"merge" => run_merge_cli, | |||||
"bench" => run_bench_cli, | |||||
_ => panic!("Subcommand {} is unknown", subcommand) | _ => panic!("Subcommand {} is unknown", subcommand) | ||||
}; | }; | ||||
run_cli(options).unwrap(); | run_cli(options).unwrap(); | ||||