mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 10:07:40 +08:00
facets: Handle boolean and skip empty strings
This commit is contained in:
parent
477077bdc2
commit
ca779c21f9
@ -207,7 +207,7 @@ impl FacetedDocidsExtractor {
|
|||||||
}
|
}
|
||||||
// String
|
// String
|
||||||
// key: fid - level - truncated_string
|
// key: fid - level - truncated_string
|
||||||
Value::String(s) => {
|
Value::String(s) if !s.is_empty() => {
|
||||||
let mut string = BVec::new_in(doc_alloc);
|
let mut string = BVec::new_in(doc_alloc);
|
||||||
string.extend_from_slice(s.as_bytes());
|
string.extend_from_slice(s.as_bytes());
|
||||||
facet_fn(del_add_facet_value, fid, string, FacetKind::String);
|
facet_fn(del_add_facet_value, fid, string, FacetKind::String);
|
||||||
@ -221,6 +221,20 @@ impl FacetedDocidsExtractor {
|
|||||||
buffer.extend_from_slice(truncated.as_bytes());
|
buffer.extend_from_slice(truncated.as_bytes());
|
||||||
cache_fn(cached_sorter, &buffer, docid)
|
cache_fn(cached_sorter, &buffer, docid)
|
||||||
}
|
}
|
||||||
|
/// Bool is handled as a string
|
||||||
|
Value::Bool(b) => {
|
||||||
|
let b = if *b { "true" } else { "false" };
|
||||||
|
let mut string = BVec::new_in(doc_alloc);
|
||||||
|
string.extend_from_slice(b.as_bytes());
|
||||||
|
facet_fn(del_add_facet_value, fid, string, FacetKind::String);
|
||||||
|
|
||||||
|
buffer.clear();
|
||||||
|
buffer.push(FacetKind::String as u8);
|
||||||
|
buffer.extend_from_slice(&fid.to_be_bytes());
|
||||||
|
buffer.push(0); // level 0
|
||||||
|
buffer.extend_from_slice(b.as_bytes());
|
||||||
|
cache_fn(cached_sorter, &buffer, docid)
|
||||||
|
}
|
||||||
// Null
|
// Null
|
||||||
// key: fid
|
// key: fid
|
||||||
Value::Null if depth == perm_json_p::Depth::OnBaseKey => {
|
Value::Null if depth == perm_json_p::Depth::OnBaseKey => {
|
||||||
@ -237,6 +251,12 @@ impl FacetedDocidsExtractor {
|
|||||||
buffer.extend_from_slice(&fid.to_be_bytes());
|
buffer.extend_from_slice(&fid.to_be_bytes());
|
||||||
cache_fn(cached_sorter, &buffer, docid)
|
cache_fn(cached_sorter, &buffer, docid)
|
||||||
}
|
}
|
||||||
|
Value::String(_) => {
|
||||||
|
buffer.clear();
|
||||||
|
buffer.push(FacetKind::Empty as u8);
|
||||||
|
buffer.extend_from_slice(&fid.to_be_bytes());
|
||||||
|
cache_fn(cached_sorter, &buffer, docid)
|
||||||
|
}
|
||||||
Value::Object(o) if o.is_empty() && depth == perm_json_p::Depth::OnBaseKey => {
|
Value::Object(o) if o.is_empty() && depth == perm_json_p::Depth::OnBaseKey => {
|
||||||
buffer.clear();
|
buffer.clear();
|
||||||
buffer.push(FacetKind::Empty as u8);
|
buffer.push(FacetKind::Empty as u8);
|
||||||
@ -244,7 +264,6 @@ impl FacetedDocidsExtractor {
|
|||||||
cache_fn(cached_sorter, &buffer, docid)
|
cache_fn(cached_sorter, &buffer, docid)
|
||||||
}
|
}
|
||||||
// Otherwise, do nothing
|
// Otherwise, do nothing
|
||||||
/// TODO: What about Value::Bool?
|
|
||||||
_ => Ok(()),
|
_ => Ok(()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user