sort facetsDistribution attribute

This commit is contained in:
gorogoroumaru 2020-10-02 20:00:55 +09:00
parent ae2de4d0c4
commit 5a98f1f076
3 changed files with 6 additions and 5 deletions

View File

@ -1,4 +1,5 @@
use std::collections::hash_map::{Entry, HashMap};
use std::collections::BTreeMap;
use std::fs::File;
use std::path::Path;
use std::sync::{Arc, RwLock};
@ -554,7 +555,7 @@ impl Database {
}
// convert attributes to their names
let frequency: HashMap<_, _> = fields_frequency
let frequency: BTreeMap<_, _> = fields_frequency
.into_iter()
.filter_map(|(a, c)| schema.name(a).map(|name| (name.to_string(), c)))
.collect();

View File

@ -1,5 +1,5 @@
use std::borrow::Cow;
use std::collections::HashMap;
use std::collections::BTreeMap;
use chrono::{DateTime, Utc};
use heed::types::{ByteSlice, OwnedType, SerdeBincode, Str, CowSlice};
@ -31,7 +31,7 @@ const SYNONYMS_KEY: &str = "synonyms";
const UPDATED_AT_KEY: &str = "updated-at";
const WORDS_KEY: &str = "words";
pub type FreqsMap = HashMap<String, usize>;
pub type FreqsMap = BTreeMap<String, usize>;
type SerdeFreqsMap = SerdeBincode<FreqsMap>;
type SerdeDatetime = SerdeBincode<DateTime<Utc>>;

View File

@ -1,4 +1,4 @@
use std::collections::HashMap;
use std::collections::{HashMap, BTreeMap};
use actix_web::web;
use actix_web::HttpResponse;
@ -24,7 +24,7 @@ pub fn services(cfg: &mut web::ServiceConfig) {
struct IndexStatsResponse {
number_of_documents: u64,
is_indexing: bool,
fields_distribution: HashMap<String, usize>,
fields_distribution: BTreeMap<String, usize>,
}
#[get("/indexes/{index_uid}/stats", wrap = "Authentication::Private")]