mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-27 04:25:06 +08:00
fix un-rankable fields errors; fix #463
This commit is contained in:
parent
3845b89a16
commit
2d7a1bfce0
@ -11,6 +11,13 @@ pub enum Number {
|
|||||||
Unsigned(u64),
|
Unsigned(u64),
|
||||||
Signed(i64),
|
Signed(i64),
|
||||||
Float(OrderedFloat<f64>),
|
Float(OrderedFloat<f64>),
|
||||||
|
Null,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Number {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::Null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for Number {
|
impl FromStr for Number {
|
||||||
@ -56,7 +63,7 @@ impl PartialOrd for Number {
|
|||||||
|
|
||||||
impl Ord for Number {
|
impl Ord for Number {
|
||||||
fn cmp(&self, other: &Self) -> Ordering {
|
fn cmp(&self, other: &Self) -> Ordering {
|
||||||
use Number::{Float, Signed, Unsigned};
|
use Number::{Float, Signed, Unsigned, Null};
|
||||||
|
|
||||||
match (*self, *other) {
|
match (*self, *other) {
|
||||||
(Unsigned(a), Unsigned(b)) => a.cmp(&b),
|
(Unsigned(a), Unsigned(b)) => a.cmp(&b),
|
||||||
@ -80,6 +87,9 @@ impl Ord for Number {
|
|||||||
(Float(a), Unsigned(b)) => a.cmp(&OrderedFloat(b as f64)),
|
(Float(a), Unsigned(b)) => a.cmp(&OrderedFloat(b as f64)),
|
||||||
(Float(a), Signed(b)) => a.cmp(&OrderedFloat(b as f64)),
|
(Float(a), Signed(b)) => a.cmp(&OrderedFloat(b as f64)),
|
||||||
(Float(a), Float(b)) => a.cmp(&b),
|
(Float(a), Float(b)) => a.cmp(&b),
|
||||||
|
(Null, Null) => Ordering::Equal,
|
||||||
|
(_, Null) => Ordering::Less,
|
||||||
|
(Null, _) => Ordering::Greater,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
if schema.is_ranked(field_id) {
|
if schema.is_ranked(field_id) {
|
||||||
let number = value.serialize(ConvertToNumber)?;
|
let number = value.serialize(ConvertToNumber).unwrap_or_default();
|
||||||
ranked_map.insert(document_id, field_id, number);
|
ranked_map.insert(document_id, field_id, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user