mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 20:15:07 +08:00
Roll back facetsDistribution
This commit is contained in:
parent
d6b53c5e7a
commit
6d24a4744f
@ -49,7 +49,7 @@ pub struct SearchQuery {
|
|||||||
#[serde(default = "Default::default")]
|
#[serde(default = "Default::default")]
|
||||||
pub matches: bool,
|
pub matches: bool,
|
||||||
pub filter: Option<Value>,
|
pub filter: Option<Value>,
|
||||||
pub facet_distributions: Option<Vec<String>>,
|
pub facets_distribution: Option<Vec<String>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
@ -73,7 +73,7 @@ pub struct SearchResult {
|
|||||||
pub offset: usize,
|
pub offset: usize,
|
||||||
pub processing_time_ms: u128,
|
pub processing_time_ms: u128,
|
||||||
#[serde(skip_serializing_if = "Option::is_none")]
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
pub facet_distributions: Option<BTreeMap<String, BTreeMap<String, u64>>>,
|
pub facets_distribution: Option<BTreeMap<String, BTreeMap<String, u64>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
@ -198,13 +198,13 @@ impl Index {
|
|||||||
|
|
||||||
let nb_hits = candidates.len();
|
let nb_hits = candidates.len();
|
||||||
|
|
||||||
let facet_distributions = match query.facet_distributions {
|
let facets_distribution = match query.facets_distribution {
|
||||||
Some(ref fields) => {
|
Some(ref fields) => {
|
||||||
let mut facet_distribution = self.facets_distribution(&rtxn);
|
let mut facets_distribution = self.facets_distribution(&rtxn);
|
||||||
if fields.iter().all(|f| f != "*") {
|
if fields.iter().all(|f| f != "*") {
|
||||||
facet_distribution.facets(fields);
|
facets_distribution.facets(fields);
|
||||||
}
|
}
|
||||||
let distribution = facet_distribution.candidates(candidates).execute()?;
|
let distribution = facets_distribution.candidates(candidates).execute()?;
|
||||||
|
|
||||||
Some(distribution)
|
Some(distribution)
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ impl Index {
|
|||||||
limit: query.limit,
|
limit: query.limit,
|
||||||
offset: query.offset.unwrap_or_default(),
|
offset: query.offset.unwrap_or_default(),
|
||||||
processing_time_ms: before_search.elapsed().as_millis(),
|
processing_time_ms: before_search.elapsed().as_millis(),
|
||||||
facet_distributions,
|
facets_distribution,
|
||||||
};
|
};
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ pub struct SearchQueryGet {
|
|||||||
filter: Option<String>,
|
filter: Option<String>,
|
||||||
#[serde(default = "Default::default")]
|
#[serde(default = "Default::default")]
|
||||||
matches: bool,
|
matches: bool,
|
||||||
facet_distributions: Option<String>,
|
facets_distribution: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SearchQueryGet> for SearchQuery {
|
impl From<SearchQueryGet> for SearchQuery {
|
||||||
@ -45,8 +45,8 @@ impl From<SearchQueryGet> for SearchQuery {
|
|||||||
.attributes_to_highlight
|
.attributes_to_highlight
|
||||||
.map(|attrs| attrs.split(',').map(String::from).collect::<HashSet<_>>());
|
.map(|attrs| attrs.split(',').map(String::from).collect::<HashSet<_>>());
|
||||||
|
|
||||||
let facet_distributions = other
|
let facets_distribution = other
|
||||||
.facet_distributions
|
.facets_distribution
|
||||||
.map(|attrs| attrs.split(',').map(String::from).collect::<Vec<_>>());
|
.map(|attrs| attrs.split(',').map(String::from).collect::<Vec<_>>());
|
||||||
|
|
||||||
let filter = match other.filter {
|
let filter = match other.filter {
|
||||||
@ -67,7 +67,7 @@ impl From<SearchQueryGet> for SearchQuery {
|
|||||||
attributes_to_highlight,
|
attributes_to_highlight,
|
||||||
filter,
|
filter,
|
||||||
matches: other.matches,
|
matches: other.matches,
|
||||||
facet_distributions,
|
facets_distribution,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user