mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-12-04 02:55:20 +08:00
Order documents by the first custom criterion on basic searches
This commit is contained in:
parent
e0cc7faea1
commit
d8e25a0863
@ -277,7 +277,19 @@ impl<'a> Search<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let found_words = derived_words.into_iter().flat_map(|(w, _)| w).map(|(w, _)| w).collect();
|
let found_words = derived_words.into_iter().flat_map(|(w, _)| w).map(|(w, _)| w).collect();
|
||||||
let documents_ids = documents.into_iter().flatten().take(limit).collect();
|
let documents_ids = match order_by_facet {
|
||||||
|
Some((fid, ftype, order)) => {
|
||||||
|
let mut ordered_documents = Vec::new();
|
||||||
|
for documents_ids in documents {
|
||||||
|
let docids = self.facet_ordered(fid, ftype, order, documents_ids, limit)?;
|
||||||
|
ordered_documents.push(docids);
|
||||||
|
if ordered_documents.iter().map(Vec::len).sum::<usize>() >= limit { break }
|
||||||
|
}
|
||||||
|
ordered_documents.into_iter().flatten().take(limit).collect()
|
||||||
|
},
|
||||||
|
None => documents.into_iter().flatten().take(limit).collect(),
|
||||||
|
};
|
||||||
|
|
||||||
Ok(SearchResult { found_words, documents_ids })
|
Ok(SearchResult { found_words, documents_ids })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user