You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
538B

  1. extern crate tantivy;
  2. use tantivy::Index;
  3. use std::path::PathBuf;
  4. use clap::ArgMatches;
  5. pub fn run_merge_cli(argmatch: &ArgMatches) -> Result<(), String> {
  6. let index_directory = PathBuf::from(argmatch.value_of("index").unwrap());
  7. run_merge(index_directory).map_err(|e| format!("Indexing failed : {:?}", e))
  8. }
  9. fn run_merge(path: PathBuf) -> tantivy::Result<()> {
  10. let index = try!(Index::open(&path));
  11. let segments = index.segments();
  12. let mut index_writer = try!(index.writer());
  13. index_writer.merge(&segments)
  14. }