fix: Prefer using the group_id instead of the product_id

The product_id is an id that identify each group variant (e.g. color, size...), it is not useful for the relevance for the moment.
This commit is contained in:
Clément Renault 2018-09-15 21:03:18 +02:00
parent d8ad4f5063
commit 626f69737e

View File

@ -17,7 +17,7 @@ use unidecode::unidecode;
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct Product { struct Product {
title: String, title: String,
product_id: u64, group_id: u64,
ft: String, ft: String,
} }
@ -76,7 +76,7 @@ fn main() {
let words = title.chain(description); let words = title.chain(description);
for (i, (attr, word)) in words { for (i, (attr, word)) in words {
let doc_index = DocIndex { let doc_index = DocIndex {
document: product.product_id, document: product.group_id,
attribute: attr, attribute: attr,
attribute_index: i as u32, attribute_index: i as u32,
}; };
@ -95,11 +95,11 @@ fn main() {
// TODO simplify this by using functions and // TODO simplify this by using functions and
// use the MetadataBuilder internal BTreeMap ? // use the MetadataBuilder internal BTreeMap ?
let key = format!("{}-title", product.product_id); let key = format!("{}-title", product.group_id);
let value = product.title; let value = product.title;
fields.insert(key, value); fields.insert(key, value);
let key = format!("{}-description", product.product_id); let key = format!("{}-description", product.group_id);
let value = product.ft; let value = product.ft;
fields.insert(key, value); fields.insert(key, value);
} }