mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-07-27 00:31:02 +00:00
nested fields
This commit is contained in:
@ -97,7 +97,8 @@ mod test {
|
||||
update_method: IndexDocumentsMethod::ReplaceDocuments,
|
||||
..Default::default()
|
||||
};
|
||||
let mut addition = IndexDocuments::new(&mut txn, &index, &config, indexing_config, |_| ());
|
||||
let mut addition =
|
||||
IndexDocuments::new(&mut txn, &index, &config, indexing_config, |_| ()).unwrap();
|
||||
|
||||
let reader =
|
||||
crate::documents::DocumentBatchReader::from_reader(Cursor::new(&*JSON)).unwrap();
|
||||
|
@ -220,9 +220,13 @@ impl<'a> FacetDistribution<'a> {
|
||||
pub fn execute(&self) -> Result<BTreeMap<String, BTreeMap<String, u64>>> {
|
||||
let fields_ids_map = self.index.fields_ids_map(self.rtxn)?;
|
||||
let filterable_fields = self.index.filterable_fields(self.rtxn)?;
|
||||
|
||||
let fields = match self.facets {
|
||||
Some(ref facets) => {
|
||||
let invalid_fields: HashSet<_> = facets.difference(&filterable_fields).collect();
|
||||
let invalid_fields: HashSet<_> = facets
|
||||
.iter()
|
||||
.filter(|facet| !crate::is_faceted(facet, &filterable_fields))
|
||||
.collect();
|
||||
if !invalid_fields.is_empty() {
|
||||
return Err(UserError::InvalidFacetsDistribution {
|
||||
invalid_facets_name: invalid_fields.into_iter().cloned().collect(),
|
||||
@ -236,10 +240,12 @@ impl<'a> FacetDistribution<'a> {
|
||||
};
|
||||
|
||||
let mut distribution = BTreeMap::new();
|
||||
for name in fields {
|
||||
if let Some(fid) = fields_ids_map.id(&name) {
|
||||
for (fid, name) in fields_ids_map.iter() {
|
||||
if crate::is_faceted(name, &fields) {
|
||||
let values = self.facet_values(fid)?;
|
||||
distribution.insert(name, values);
|
||||
if !values.is_empty() {
|
||||
distribution.insert(name.to_string(), values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,7 +353,8 @@ impl<'a> Filter<'a> {
|
||||
match &self.condition {
|
||||
FilterCondition::Condition { fid, op } => {
|
||||
let filterable_fields = index.filterable_fields(rtxn)?;
|
||||
if filterable_fields.contains(fid.value()) {
|
||||
|
||||
if crate::is_faceted(fid.value(), &filterable_fields) {
|
||||
let field_ids_map = index.fields_ids_map(rtxn)?;
|
||||
if let Some(fid) = field_ids_map.id(fid.value()) {
|
||||
Self::evaluate_operator(rtxn, index, numbers_db, strings_db, fid, &op)
|
||||
@ -549,7 +550,6 @@ mod tests {
|
||||
Filter::from_str("channel = gotaga AND (timestamp = 44 OR channel != ponce)")
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
println!("\nExpecting: {:#?}\nGot: {:#?}\n", expected, condition);
|
||||
assert_eq!(condition, expected);
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ impl<'a> Search<'a> {
|
||||
let sortable_fields = self.index.sortable_fields(self.rtxn)?;
|
||||
for asc_desc in sort_criteria {
|
||||
match asc_desc.member() {
|
||||
Member::Field(ref field) if !sortable_fields.contains(field) => {
|
||||
Member::Field(ref field) if !crate::is_faceted(field, &sortable_fields) => {
|
||||
return Err(UserError::InvalidSortableAttribute {
|
||||
field: field.to_string(),
|
||||
valid_fields: sortable_fields.into_iter().collect(),
|
||||
|
Reference in New Issue
Block a user