mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 08:41:00 +00:00
feat: Introduce the index module
This commit is contained in:
41
examples/create-index.rs
Normal file
41
examples/create-index.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use std::path::Path;
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use elapsed::measure_time;
|
||||
use moby_name_gen::random_name;
|
||||
use structopt::StructOpt;
|
||||
|
||||
use pentium::index::update::Update;
|
||||
use pentium::index::Index;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Cmd {
|
||||
/// csv file to index
|
||||
#[structopt(parse(from_os_str))]
|
||||
pub csv_file: PathBuf,
|
||||
}
|
||||
|
||||
fn generate_update_from_csv(path: &Path) -> Result<Update, Box<Error>> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<Error>> {
|
||||
let command = Cmd::from_args();
|
||||
|
||||
let path = random_name();
|
||||
|
||||
println!("generating the update...");
|
||||
let update = generate_update_from_csv(&command.csv_file)?;
|
||||
|
||||
println!("creating the index");
|
||||
let index = Index::open(&path)?;
|
||||
|
||||
println!("ingesting the changes in the index");
|
||||
index.ingest_update(update)?;
|
||||
|
||||
println!("the index {:?} has been created!", path);
|
||||
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user