mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-22 12:54:26 +01:00
enable distinct
This commit is contained in:
parent
bf3c04f2dc
commit
ec230c2835
1414
meilisearch-http/Cargo.lock → Cargo.lock
generated
1414
meilisearch-http/Cargo.lock → Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -59,6 +59,9 @@ impl Index {
|
|||||||
})
|
})
|
||||||
.transpose()?
|
.transpose()?
|
||||||
.unwrap_or_else(BTreeSet::new);
|
.unwrap_or_else(BTreeSet::new);
|
||||||
|
let distinct_attribute = self
|
||||||
|
.distinct_attribute(&txn)?
|
||||||
|
.map(String::from);
|
||||||
|
|
||||||
Ok(Settings {
|
Ok(Settings {
|
||||||
displayed_attributes: Some(Some(displayed_attributes)),
|
displayed_attributes: Some(Some(displayed_attributes)),
|
||||||
@ -66,6 +69,7 @@ impl Index {
|
|||||||
attributes_for_faceting: Some(Some(faceted_attributes)),
|
attributes_for_faceting: Some(Some(faceted_attributes)),
|
||||||
ranking_rules: Some(Some(criteria)),
|
ranking_rules: Some(Some(criteria)),
|
||||||
stop_words: Some(Some(stop_words)),
|
stop_words: Some(Some(stop_words)),
|
||||||
|
distinct_attribute: Some(distinct_attribute),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,13 +43,18 @@ pub struct Settings {
|
|||||||
skip_serializing_if = "Option::is_none"
|
skip_serializing_if = "Option::is_none"
|
||||||
)]
|
)]
|
||||||
pub ranking_rules: Option<Option<Vec<String>>>,
|
pub ranking_rules: Option<Option<Vec<String>>>,
|
||||||
|
|
||||||
#[serde(
|
#[serde(
|
||||||
default,
|
default,
|
||||||
deserialize_with = "deserialize_some",
|
deserialize_with = "deserialize_some",
|
||||||
skip_serializing_if = "Option::is_none"
|
skip_serializing_if = "Option::is_none"
|
||||||
)]
|
)]
|
||||||
pub stop_words: Option<Option<BTreeSet<String>>>,
|
pub stop_words: Option<Option<BTreeSet<String>>>,
|
||||||
|
#[serde(
|
||||||
|
default,
|
||||||
|
deserialize_with = "deserialize_some",
|
||||||
|
skip_serializing_if = "Option::is_none"
|
||||||
|
)]
|
||||||
|
pub distinct_attribute: Option<Option<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
@ -60,6 +65,7 @@ impl Settings {
|
|||||||
attributes_for_faceting: Some(None),
|
attributes_for_faceting: Some(None),
|
||||||
ranking_rules: Some(None),
|
ranking_rules: Some(None),
|
||||||
stop_words: Some(None),
|
stop_words: Some(None),
|
||||||
|
distinct_attribute: Some(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -145,7 +151,6 @@ impl Index {
|
|||||||
let mut wtxn = self.write_txn()?;
|
let mut wtxn = self.write_txn()?;
|
||||||
let mut builder = update_builder.settings(&mut wtxn, self);
|
let mut builder = update_builder.settings(&mut wtxn, self);
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
|
||||||
if let Some(ref names) = settings.searchable_attributes {
|
if let Some(ref names) = settings.searchable_attributes {
|
||||||
match names {
|
match names {
|
||||||
Some(names) => builder.set_searchable_fields(names.clone()),
|
Some(names) => builder.set_searchable_fields(names.clone()),
|
||||||
@ -153,7 +158,6 @@ impl Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
|
||||||
if let Some(ref names) = settings.displayed_attributes {
|
if let Some(ref names) = settings.displayed_attributes {
|
||||||
match names {
|
match names {
|
||||||
Some(names) => builder.set_displayed_fields(names.clone()),
|
Some(names) => builder.set_displayed_fields(names.clone()),
|
||||||
@ -161,13 +165,11 @@ impl Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
|
||||||
if let Some(ref facet_types) = settings.attributes_for_faceting {
|
if let Some(ref facet_types) = settings.attributes_for_faceting {
|
||||||
let facet_types = facet_types.clone().unwrap_or_else(HashMap::new);
|
let facet_types = facet_types.clone().unwrap_or_else(HashMap::new);
|
||||||
builder.set_faceted_fields(facet_types);
|
builder.set_faceted_fields(facet_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
|
||||||
if let Some(ref criteria) = settings.ranking_rules {
|
if let Some(ref criteria) = settings.ranking_rules {
|
||||||
match criteria {
|
match criteria {
|
||||||
Some(criteria) => builder.set_criteria(criteria.clone()),
|
Some(criteria) => builder.set_criteria(criteria.clone()),
|
||||||
@ -175,7 +177,6 @@ impl Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We transpose the settings JSON struct into a real setting update.
|
|
||||||
if let Some(ref stop_words) = settings.stop_words {
|
if let Some(ref stop_words) = settings.stop_words {
|
||||||
match stop_words {
|
match stop_words {
|
||||||
Some(stop_words) => builder.set_stop_words(stop_words.clone()),
|
Some(stop_words) => builder.set_stop_words(stop_words.clone()),
|
||||||
@ -183,6 +184,13 @@ impl Index {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(ref distinct_attribute) = settings.distinct_attribute {
|
||||||
|
match distinct_attribute {
|
||||||
|
Some(attr) => builder.set_distinct_attribute(attr.clone()),
|
||||||
|
None => builder.reset_distinct_attribute(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let result = builder
|
let result = builder
|
||||||
.execute(|indexing_step, update_id| info!("update {}: {:?}", update_id, indexing_step));
|
.execute(|indexing_step, update_id| info!("update {}: {:?}", update_id, indexing_step));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user