support wildcard

This commit is contained in:
Marin Postma 2021-04-20 13:10:50 +02:00
parent 881b099c8e
commit 7a737d2bd3
No known key found for this signature in database
GPG Key ID: D5241F0C0C865F30

View File

@ -41,7 +41,7 @@ pub struct SearchQuery {
pub struct SearchHit {
#[serde(flatten)]
pub document: Document,
#[serde(rename = "_formatted", skip_serializing_if = "Map::is_empty")]
#[serde(rename = "_formatted", skip_serializing_if = "Document::is_empty")]
pub formatted: Document,
}
@ -88,15 +88,23 @@ impl Index {
let mut documents = Vec::new();
let fields_ids_map = self.fields_ids_map(&rtxn).unwrap();
let fids = |attrs: &HashSet<String>| {
attrs
.iter()
.filter_map(|name| fields_ids_map.id(name))
.collect()
};
let displayed_ids: HashSet<FieldId> = fields_ids_map.iter().map(|(id, _)| id).collect();
let fids = |attrs: &HashSet<String>| {
let mut ids = HashSet::new();
for attr in attrs {
if attr == "*" {
ids = displayed_ids.clone();
break;
}
if let Some(id) = fields_ids_map.id(attr) {
ids.insert(id);
}
}
ids
};
let to_retrieve_ids = query
.attributes_to_retrieve
.as_ref()