Browse Source

NOBUG reenabled various commands.

develop
Paul Masurel 6 years ago
parent
commit
2968ccfc5d
4 changed files with 31 additions and 19 deletions
  1. +13
    -1
      src/commands/index.rs
  2. +10
    -10
      src/commands/mod.rs
  3. +2
    -3
      src/commands/search.rs
  4. +6
    -5
      src/main.rs

+ 13
- 1
src/commands/index.rs View File

@@ -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);
for _ in 0..num_threads_to_parse_json {
let schema_clone = schema.clone();
@@ -84,13 +84,25 @@ fn run_index(directory: PathBuf,
index_writer.set_merge_policy(Box::new(NoMergePolicy));
}

let start_overall = PreciseTime::now();
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 {
Ok(docstamp) => {
println!("Commit succeed, docstamp at {}", docstamp);
println!("Waiting for merging threads");
index_writer.wait_merging_threads()?;
println!("Terminated successfully!");
{
let duration = start_overall.to(PreciseTime::now());
info!("Indexing the documents took {} overall (indexing + merge)", duration.num_seconds());
}
Ok(())
}
Err(e) => {


+ 10
- 10
src/commands/mod.rs View File

@@ -1,13 +1,13 @@
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::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;

+ 2
- 3
src/commands/search.rs View File

@@ -12,9 +12,8 @@ use tantivy::schema::FieldType;
pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> {
let index_directory = PathBuf::from(matches.value_of("index").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<()> {


+ 6
- 5
src/main.rs View File

@@ -22,6 +22,7 @@ extern crate byteorder;
#[macro_use]
extern crate serde_derive;


use clap::{AppSettings, Arg, App, SubCommand};
mod commands;
use self::commands::*;
@@ -128,12 +129,12 @@ fn main() {
let (subcommand, some_options) = cli_options.subcommand();
let options = some_options.unwrap();
let run_cli = match subcommand {
// "new" => run_new_cli,
"new" => run_new_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)
};
run_cli(options).unwrap();


Loading…
Cancel
Save