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.

21 lines
592B

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