From 12863980d459212ef8162e9db0d0f688795b68c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Tue, 11 Dec 2018 12:06:02 +0100 Subject: [PATCH] feat: Adapt the examples to the kaggle dataset --- examples/create-database.rs | 41 +++++++++++-------------------------- examples/query-database.rs | 13 ++++-------- 2 files changed, 16 insertions(+), 38 deletions(-) diff --git a/examples/create-database.rs b/examples/create-database.rs index 095a20f9a..b66bf7f5b 100644 --- a/examples/create-database.rs +++ b/examples/create-database.rs @@ -23,21 +23,11 @@ pub struct Opt { } #[derive(Debug, Serialize, Deserialize)] -#[allow(non_snake_case)] struct Document<'a> { - skuId: &'a str, - productGroup: &'a str, - fr_FR_commercialName: &'a str, - en_GB_commercialName: &'a str, - maketingColorInternalName: &'a str, - materialInternalName: &'a str, - fr_FR_description: &'a str, - fr_FR_detailedDescription: &'a str, - fr_FR_Price: &'a str, - fr_FR_images_url: &'a str, - en_GB_description: &'a str, - en_GB_detailedDescription: &'a str, - en_GB_Price: &'a str, + id: &'a str, + title: &'a str, + description: &'a str, + image: &'a str, } fn calculate_hash(t: &T) -> u64 { @@ -48,19 +38,10 @@ fn calculate_hash(t: &T) -> u64 { fn create_schema() -> Schema { let mut schema = SchemaBuilder::new(); - schema.new_attribute("skuId", STORED | INDEXED); - schema.new_attribute("productGroup", STORED | INDEXED); - schema.new_attribute("fr_FR_commercialName", STORED | INDEXED); - schema.new_attribute("en_GB_commercialName", STORED | INDEXED); - schema.new_attribute("maketingColorInternalName", STORED | INDEXED); - schema.new_attribute("materialInternalName", STORED | INDEXED); - schema.new_attribute("fr_FR_description", STORED | INDEXED); - schema.new_attribute("fr_FR_detailedDescription", STORED); - schema.new_attribute("fr_FR_Price", STORED); - schema.new_attribute("fr_FR_images_url", STORED); - schema.new_attribute("en_GB_description", STORED | INDEXED); - schema.new_attribute("en_GB_detailedDescription", STORED); - schema.new_attribute("en_GB_Price", STORED); + schema.new_attribute("id", STORED); + schema.new_attribute("title", STORED | INDEXED); + schema.new_attribute("description", STORED | INDEXED); + schema.new_attribute("image", STORED); schema.build() } @@ -86,7 +67,7 @@ fn index(schema: Schema, database_path: &Path, csv_data_path: &Path) -> Result Result<(), Box> { index(schema, &opt.database_path, &opt.csv_data_path) }); - let _ = result?; + if let Err(e) = result { + return Err(e.into()) + } println!("database created in {} at: {:?}", elapsed, opt.database_path); diff --git a/examples/query-database.rs b/examples/query-database.rs index 57a17990d..804741751 100644 --- a/examples/query-database.rs +++ b/examples/query-database.rs @@ -19,16 +19,11 @@ pub struct Opt { } #[derive(Debug, Serialize, Deserialize)] -#[allow(non_snake_case)] struct Document { - skuId: String, - productGroup: String, - fr_FR_commercialName: String, - en_GB_commercialName: String, - maketingColorInternalName: String, - materialInternalName: String, - fr_FR_description: String, - en_GB_description: String, + id: String, + title: String, + description: String, + image: String, } fn main() -> Result<(), Box> {