mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-27 07:14:26 +01:00
Merge #906
906: Facet distribution correct case r=LegendreM a=MarinPostma ~ Co-authored-by: mpostma <postma.marin@protonmail.com> Co-authored-by: marin <postma.marin@protonmail.com>
This commit is contained in:
commit
1903302a74
@ -39,7 +39,7 @@ pub fn bucket_sort<'c, FI>(
|
||||
query: &str,
|
||||
range: Range<usize>,
|
||||
facets_docids: Option<SetBuf<DocumentId>>,
|
||||
facet_count_docids: Option<HashMap<String, HashMap<String, Cow<Set<DocumentId>>>>>,
|
||||
facet_count_docids: Option<HashMap<String, HashMap<String, (&str, Cow<Set<DocumentId>>)>>>,
|
||||
filter: Option<FI>,
|
||||
criteria: Criteria<'c>,
|
||||
searchable_attrs: Option<ReorderedAttrs>,
|
||||
@ -199,7 +199,7 @@ pub fn bucket_sort_with_distinct<'c, FI, FD>(
|
||||
query: &str,
|
||||
range: Range<usize>,
|
||||
facets_docids: Option<SetBuf<DocumentId>>,
|
||||
facet_count_docids: Option<HashMap<String, HashMap<String, Cow<Set<DocumentId>>>>>,
|
||||
facet_count_docids: Option<HashMap<String, HashMap<String, (&str, Cow<Set<DocumentId>>)>>>,
|
||||
filter: Option<FI>,
|
||||
distinct: FD,
|
||||
distinct_size: usize,
|
||||
@ -637,17 +637,17 @@ pub fn placeholder_document_sort(
|
||||
|
||||
/// For each entry in facet_docids, calculates the number of documents in the intersection with candidate_docids.
|
||||
pub fn facet_count(
|
||||
facet_docids: HashMap<String, HashMap<String, Cow<Set<DocumentId>>>>,
|
||||
facet_docids: HashMap<String, HashMap<String, (&str, Cow<Set<DocumentId>>)>>,
|
||||
candidate_docids: &Set<DocumentId>,
|
||||
) -> HashMap<String, HashMap<String, usize>> {
|
||||
let mut facets_counts = HashMap::with_capacity(facet_docids.len());
|
||||
for (key, doc_map) in facet_docids {
|
||||
let mut count_map = HashMap::with_capacity(doc_map.len());
|
||||
for (value, docids) in doc_map {
|
||||
for (_, (value, docids)) in doc_map {
|
||||
let mut counter = Counter::new();
|
||||
let op = OpBuilder::new(docids.as_ref(), candidate_docids).intersection();
|
||||
SetOperation::<DocumentId>::extend_collection(op, &mut counter);
|
||||
count_map.insert(value, counter.0);
|
||||
count_map.insert(value.to_string(), counter.0);
|
||||
}
|
||||
facets_counts.insert(key, count_map);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ impl<'a> heed::BytesDecode<'a> for FacetKey {
|
||||
}
|
||||
|
||||
pub fn add_to_facet_map(
|
||||
facet_map: &mut HashMap<FacetKey, Vec<DocumentId>>,
|
||||
facet_map: &mut HashMap<FacetKey, (String, Vec<DocumentId>)>,
|
||||
field_id: FieldId,
|
||||
value: Value,
|
||||
document_id: DocumentId,
|
||||
@ -175,8 +175,8 @@ pub fn add_to_facet_map(
|
||||
Value::Null => return Ok(()),
|
||||
value => return Err(FacetError::InvalidDocumentAttribute(value.to_string())),
|
||||
};
|
||||
let key = FacetKey::new(field_id, value);
|
||||
facet_map.entry(key).or_insert_with(Vec::new).push(document_id);
|
||||
let key = FacetKey::new(field_id, value.clone());
|
||||
facet_map.entry(key).or_insert_with(|| (value, Vec::new())).1.push(document_id);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -185,8 +185,10 @@ pub fn facet_map_from_docids(
|
||||
index: &crate::Index,
|
||||
document_ids: &[DocumentId],
|
||||
attributes_for_facetting: &[FieldId],
|
||||
) -> MResult<HashMap<FacetKey, Vec<DocumentId>>> {
|
||||
let mut facet_map = HashMap::new();
|
||||
) -> MResult<HashMap<FacetKey, (String, Vec<DocumentId>)>> {
|
||||
// A hashmap that ascociate a facet key to a pair containing the original facet attribute
|
||||
// string with it's case preserved, and a list of document ids for that facet attribute.
|
||||
let mut facet_map: HashMap<FacetKey, (String, Vec<DocumentId>)> = HashMap::new();
|
||||
for document_id in document_ids {
|
||||
for result in index
|
||||
.documents_fields
|
||||
@ -212,7 +214,7 @@ pub fn facet_map_from_docs(
|
||||
schema: &Schema,
|
||||
documents: &HashMap<DocumentId, IndexMap<String, Value>>,
|
||||
attributes_for_facetting: &[FieldId],
|
||||
) -> MResult<HashMap<FacetKey, Vec<DocumentId>>> {
|
||||
) -> MResult<HashMap<FacetKey, (String, Vec<DocumentId>)>> {
|
||||
let mut facet_map = HashMap::new();
|
||||
let attributes_for_facetting = attributes_for_facetting
|
||||
.iter()
|
||||
|
@ -97,16 +97,14 @@ impl<'c, 'f, 'd, 'i> QueryBuilder<'c, 'f, 'd, 'i> {
|
||||
.unwrap_or_default();
|
||||
ors.push(docids);
|
||||
}
|
||||
let sets: Vec<_> = ors.iter().map(Cow::deref).collect();
|
||||
let or_result = sdset::multi::OpBuilder::from_vec(sets)
|
||||
.union()
|
||||
.into_set_buf();
|
||||
let sets: Vec<_> = ors.iter().map(|(_, i)| i).map(Cow::deref).collect();
|
||||
let or_result = sdset::multi::OpBuilder::from_vec(sets).union().into_set_buf();
|
||||
ands.push(Cow::Owned(or_result));
|
||||
ors.clear();
|
||||
}
|
||||
Either::Right(key) => {
|
||||
match self.index.facets.facet_document_ids(reader, &key)? {
|
||||
Some(docids) => ands.push(docids),
|
||||
Some((_name, docids)) => ands.push(docids),
|
||||
// no candidates for search, early return.
|
||||
None => return Ok(Some(SetBuf::default())),
|
||||
}
|
||||
@ -206,7 +204,7 @@ impl<'c, 'f, 'd, 'i> QueryBuilder<'c, 'f, 'd, 'i> {
|
||||
}
|
||||
}
|
||||
|
||||
fn facet_count_docids<'a>(&self, reader: &'a MainReader) -> MResult<Option<HashMap<String, HashMap<String, Cow<'a, Set<DocumentId>>>>>> {
|
||||
fn facet_count_docids<'a>(&self, reader: &'a MainReader) -> MResult<Option<HashMap<String, HashMap<String, (&'a str, Cow<'a, Set<DocumentId>>)>>>> {
|
||||
match self.facets {
|
||||
Some(ref field_ids) => {
|
||||
let mut facet_count_map = HashMap::new();
|
||||
|
@ -1,12 +1,14 @@
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::mem;
|
||||
|
||||
use heed::{RwTxn, RoTxn, Result as ZResult, RoRange};
|
||||
use heed::{RwTxn, RoTxn, RoRange, types::Str, BytesEncode, BytesDecode};
|
||||
use sdset::{SetBuf, Set, SetOperation};
|
||||
|
||||
use meilisearch_types::DocumentId;
|
||||
use meilisearch_schema::FieldId;
|
||||
|
||||
use crate::MResult;
|
||||
use crate::database::MainT;
|
||||
use crate::facets::FacetKey;
|
||||
use super::cow_set::CowSet;
|
||||
@ -14,45 +16,82 @@ use super::cow_set::CowSet;
|
||||
/// contains facet info
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Facets {
|
||||
pub(crate) facets: heed::Database<FacetKey, CowSet<DocumentId>>,
|
||||
pub(crate) facets: heed::Database<FacetKey, FacetData>,
|
||||
}
|
||||
|
||||
pub struct FacetData;
|
||||
|
||||
impl<'a> BytesEncode<'a> for FacetData {
|
||||
type EItem = (&'a str, &'a Set<DocumentId>);
|
||||
|
||||
fn bytes_encode(item: &'a Self::EItem) -> Option<Cow<'a, [u8]>> {
|
||||
// get size of the first item
|
||||
let first_size = item.0.as_bytes().len();
|
||||
let size = mem::size_of::<u64>()
|
||||
+ first_size
|
||||
+ item.1.len() * mem::size_of::<DocumentId>();
|
||||
let mut buffer = Vec::with_capacity(size);
|
||||
// encode the length of the first item
|
||||
buffer.extend_from_slice(&first_size.to_be_bytes());
|
||||
buffer.extend_from_slice(Str::bytes_encode(&item.0)?.as_ref());
|
||||
let second_slice = CowSet::bytes_encode(&item.1)?;
|
||||
buffer.extend_from_slice(second_slice.as_ref());
|
||||
Some(Cow::Owned(buffer))
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> BytesDecode<'a> for FacetData {
|
||||
type DItem = (&'a str, Cow<'a, Set<DocumentId>>);
|
||||
|
||||
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
|
||||
const LEN: usize = mem::size_of::<u64>();
|
||||
let mut size_buf = [0; LEN];
|
||||
size_buf.copy_from_slice(bytes.get(0..LEN)?);
|
||||
// decode size of the first item from the bytes
|
||||
let first_size = usize::from_be_bytes(size_buf);
|
||||
// decode first and second items
|
||||
let first_item = Str::bytes_decode(bytes.get(LEN..(LEN + first_size))?)?;
|
||||
let second_item = CowSet::bytes_decode(bytes.get((LEN + first_size)..)?)?;
|
||||
Some((first_item, second_item))
|
||||
}
|
||||
}
|
||||
|
||||
impl Facets {
|
||||
// we use sdset::SetBuf to ensure the docids are sorted.
|
||||
pub fn put_facet_document_ids(&self, writer: &mut RwTxn<MainT>, facet_key: FacetKey, doc_ids: &Set<DocumentId>) -> ZResult<()> {
|
||||
self.facets.put(writer, &facet_key, doc_ids)
|
||||
pub fn put_facet_document_ids(&self, writer: &mut RwTxn<MainT>, facet_key: FacetKey, doc_ids: &Set<DocumentId>, facet_value: &str) -> MResult<()> {
|
||||
Ok(self.facets.put(writer, &facet_key, &(facet_value, doc_ids))?)
|
||||
}
|
||||
|
||||
pub fn field_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, field_id: FieldId) -> ZResult<RoRange<'txn, FacetKey, CowSet<DocumentId>>> {
|
||||
self.facets.prefix_iter(reader, &FacetKey::new(field_id, String::new()))
|
||||
pub fn field_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, field_id: FieldId) -> MResult<RoRange<'txn, FacetKey, FacetData>> {
|
||||
Ok(self.facets.prefix_iter(reader, &FacetKey::new(field_id, String::new()))?)
|
||||
}
|
||||
|
||||
pub fn facet_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, facet_key: &FacetKey) -> ZResult<Option<Cow<'txn, Set<DocumentId>>>> {
|
||||
self.facets.get(reader, &facet_key)
|
||||
pub fn facet_document_ids<'txn>(&self, reader: &'txn RoTxn<MainT>, facet_key: &FacetKey) -> MResult<Option<(&'txn str,Cow<'txn, Set<DocumentId>>)>> {
|
||||
Ok(self.facets.get(reader, &facet_key)?)
|
||||
}
|
||||
|
||||
/// updates the facets store, revmoving the documents from the facets provided in the
|
||||
/// `facet_map` argument
|
||||
pub fn remove(&self, writer: &mut RwTxn<MainT>, facet_map: HashMap<FacetKey, Vec<DocumentId>>) -> ZResult<()> {
|
||||
for (key, document_ids) in facet_map {
|
||||
if let Some(old) = self.facets.get(writer, &key)? {
|
||||
pub fn remove(&self, writer: &mut RwTxn<MainT>, facet_map: HashMap<FacetKey, (String, Vec<DocumentId>)>) -> MResult<()> {
|
||||
for (key, (name, document_ids)) in facet_map {
|
||||
if let Some((_, old)) = self.facets.get(writer, &key)? {
|
||||
let to_remove = SetBuf::from_dirty(document_ids);
|
||||
let new = sdset::duo::OpBuilder::new(old.as_ref(), to_remove.as_set()).difference().into_set_buf();
|
||||
self.facets.put(writer, &key, new.as_set())?;
|
||||
self.facets.put(writer, &key, &(&name, new.as_set()))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add(&self, writer: &mut RwTxn<MainT>, facet_map: HashMap<FacetKey, Vec<DocumentId>>) -> ZResult<()> {
|
||||
for (key, document_ids) in facet_map {
|
||||
pub fn add(&self, writer: &mut RwTxn<MainT>, facet_map: HashMap<FacetKey, (String, Vec<DocumentId>)>) -> MResult<()> {
|
||||
for (key, (facet_name, document_ids)) in facet_map {
|
||||
let set = SetBuf::from_dirty(document_ids);
|
||||
self.put_facet_document_ids(writer, key, set.as_set())?;
|
||||
self.put_facet_document_ids(writer, key, set.as_set(), &facet_name)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear(self, writer: &mut heed::RwTxn<MainT>) -> ZResult<()> {
|
||||
self.facets.clear(writer)
|
||||
pub fn clear(self, writer: &mut heed::RwTxn<MainT>) -> MResult<()> {
|
||||
Ok(self.facets.clear(writer)?)
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
"balance": "$2,668.55",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lucas Hess",
|
||||
"gender": "male",
|
||||
"email": "lucashess@chorizon.com",
|
||||
@ -26,7 +26,7 @@
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -90,7 +90,7 @@
|
||||
"balance": "$2,575.78",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 39,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Mariana Pacheco",
|
||||
"gender": "female",
|
||||
"email": "marianapacheco@chorizon.com",
|
||||
@ -110,7 +110,7 @@
|
||||
"balance": "$3,793.09",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 20,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Warren Watson",
|
||||
"gender": "male",
|
||||
"email": "warrenwatson@chorizon.com",
|
||||
@ -155,7 +155,7 @@
|
||||
"balance": "$1,349.50",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 28,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Chrystal Boyd",
|
||||
"gender": "female",
|
||||
"email": "chrystalboyd@chorizon.com",
|
||||
@ -235,7 +235,7 @@
|
||||
"balance": "$1,351.43",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 28,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Evans Wagner",
|
||||
"gender": "male",
|
||||
"email": "evanswagner@chorizon.com",
|
||||
@ -431,7 +431,7 @@
|
||||
"balance": "$1,986.48",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 38,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Florence Long",
|
||||
"gender": "female",
|
||||
"email": "florencelong@chorizon.com",
|
||||
@ -530,7 +530,7 @@
|
||||
"balance": "$3,973.43",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 29,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Sykes Conley",
|
||||
"gender": "male",
|
||||
"email": "sykesconley@chorizon.com",
|
||||
@ -813,7 +813,7 @@
|
||||
"balance": "$1,992.38",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 40,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Christina Short",
|
||||
"gender": "female",
|
||||
"email": "christinashort@chorizon.com",
|
||||
@ -944,7 +944,7 @@
|
||||
"balance": "$2,893.45",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 22,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Joni Spears",
|
||||
"gender": "female",
|
||||
"email": "jonispears@chorizon.com",
|
||||
@ -988,7 +988,7 @@
|
||||
"balance": "$1,348.04",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 34,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lawson Curtis",
|
||||
"gender": "male",
|
||||
"email": "lawsoncurtis@chorizon.com",
|
||||
@ -1006,7 +1006,7 @@
|
||||
"balance": "$1,132.41",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 38,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Goff May",
|
||||
"gender": "male",
|
||||
"email": "goffmay@chorizon.com",
|
||||
@ -1026,7 +1026,7 @@
|
||||
"balance": "$1,201.87",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 38,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Goodman Becker",
|
||||
"gender": "male",
|
||||
"email": "goodmanbecker@chorizon.com",
|
||||
@ -1069,7 +1069,7 @@
|
||||
"balance": "$1,947.08",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 21,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Guerra Mcintyre",
|
||||
"gender": "male",
|
||||
"email": "guerramcintyre@chorizon.com",
|
||||
@ -1153,7 +1153,7 @@
|
||||
"balance": "$2,113.29",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 28,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Richards Walls",
|
||||
"gender": "male",
|
||||
"email": "richardswalls@chorizon.com",
|
||||
@ -1211,7 +1211,7 @@
|
||||
"balance": "$1,844.56",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 20,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Kaitlin Conner",
|
||||
"gender": "female",
|
||||
"email": "kaitlinconner@chorizon.com",
|
||||
@ -1229,7 +1229,7 @@
|
||||
"balance": "$2,876.10",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 38,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Mamie Fischer",
|
||||
"gender": "female",
|
||||
"email": "mamiefischer@chorizon.com",
|
||||
@ -1252,7 +1252,7 @@
|
||||
"balance": "$1,921.58",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -1291,7 +1291,7 @@
|
||||
"balance": "$2,813.41",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 37,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Charles Castillo",
|
||||
"gender": "male",
|
||||
"email": "charlescastillo@chorizon.com",
|
||||
@ -1433,7 +1433,7 @@
|
||||
"balance": "$1,539.98",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 24,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Angelina Dyer",
|
||||
"gender": "female",
|
||||
"email": "angelinadyer@chorizon.com",
|
||||
@ -1493,7 +1493,7 @@
|
||||
"balance": "$3,381.63",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 38,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Candace Sawyer",
|
||||
"gender": "female",
|
||||
"email": "candacesawyer@chorizon.com",
|
||||
@ -1514,7 +1514,7 @@
|
||||
"balance": "$1,640.98",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Hendricks Martinez",
|
||||
"gender": "male",
|
||||
"email": "hendricksmartinez@chorizon.com",
|
||||
@ -1557,7 +1557,7 @@
|
||||
"balance": "$1,180.90",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Stark Wong",
|
||||
"gender": "male",
|
||||
"email": "starkwong@chorizon.com",
|
||||
@ -1577,7 +1577,7 @@
|
||||
"balance": "$1,913.42",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 24,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Emma Jacobs",
|
||||
"gender": "female",
|
||||
"email": "emmajacobs@chorizon.com",
|
||||
@ -1595,7 +1595,7 @@
|
||||
"balance": "$1,274.29",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 25,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Clarice Gardner",
|
||||
"gender": "female",
|
||||
"email": "claricegardner@chorizon.com",
|
||||
|
@ -156,7 +156,7 @@ async fn placeholder_search_with_filter() {
|
||||
|
||||
test_post_get_search!(server, query, |response, _status_code| {
|
||||
let hits = response["hits"].as_array().unwrap();
|
||||
assert!(hits.iter().all(|v| v["color"].as_str().unwrap() == "green"));
|
||||
assert!(hits.iter().all(|v| v["color"].as_str().unwrap() == "Green"));
|
||||
});
|
||||
|
||||
let query = json!({
|
||||
@ -177,7 +177,7 @@ async fn placeholder_search_with_filter() {
|
||||
let bug = Value::String(String::from("bug"));
|
||||
let wontfix = Value::String(String::from("wontfix"));
|
||||
assert!(hits.iter().all(|v|
|
||||
v["color"].as_str().unwrap() == "green" &&
|
||||
v["color"].as_str().unwrap() == "Green" &&
|
||||
v["tags"].as_array().unwrap().contains(&bug) ||
|
||||
v["tags"].as_array().unwrap().contains(&wontfix)));
|
||||
});
|
||||
@ -206,7 +206,7 @@ async fn placeholder_test_faceted_search_valid() {
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.all(|value| value.get("color").unwrap() == "green"));
|
||||
.all(|value| value.get("color").unwrap() == "Green"));
|
||||
});
|
||||
|
||||
let query = json!({
|
||||
@ -296,7 +296,7 @@ async fn placeholder_test_faceted_search_valid() {
|
||||
.unwrap() == "blue"
|
||||
|| value
|
||||
.get("color")
|
||||
.unwrap() == "green"));
|
||||
.unwrap() == "Green"));
|
||||
});
|
||||
// test and-or: ["tags:bug", ["color:blue", "color:green"]]
|
||||
let query = json!({
|
||||
@ -322,7 +322,7 @@ async fn placeholder_test_faceted_search_valid() {
|
||||
.unwrap() == "blue"
|
||||
|| value
|
||||
.get("color")
|
||||
.unwrap() == "green")));
|
||||
.unwrap() == "Green")));
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ async fn search_with_limit() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -42,7 +42,7 @@ async fn search_with_limit() {
|
||||
"balance": "$1,921.58",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -101,7 +101,7 @@ async fn search_with_offset() {
|
||||
"balance": "$1,921.58",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -142,7 +142,7 @@ async fn search_with_offset() {
|
||||
"balance": "$2,668.55",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lucas Hess",
|
||||
"gender": "male",
|
||||
"email": "lucashess@chorizon.com",
|
||||
@ -181,7 +181,7 @@ async fn search_with_attribute_to_highlight_wildcard() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -201,7 +201,7 @@ async fn search_with_attribute_to_highlight_wildcard() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "<em>Cherry</em> Orr",
|
||||
"gender": "female",
|
||||
"email": "<em>cherry</em>orr@chorizon.com",
|
||||
@ -241,7 +241,7 @@ async fn search_with_attribute_to_highlight_1() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -261,7 +261,7 @@ async fn search_with_attribute_to_highlight_1() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "<em>Cherry</em> Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -301,7 +301,7 @@ async fn search_with_matches() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -355,7 +355,7 @@ async fn search_with_crop() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -375,7 +375,7 @@ async fn search_with_crop() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -413,7 +413,7 @@ async fn search_with_attributes_to_retrieve() {
|
||||
{
|
||||
"name": "Cherry Orr",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"gender": "female"
|
||||
}
|
||||
]);
|
||||
@ -440,7 +440,7 @@ async fn search_with_attributes_to_retrieve_wildcard() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -478,7 +478,7 @@ async fn search_with_filter() {
|
||||
"balance": "$1,921.58",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -499,7 +499,7 @@ async fn search_with_filter() {
|
||||
"balance": "$2,668.55",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lucas Hess",
|
||||
"gender": "male",
|
||||
"email": "lucashess@chorizon.com",
|
||||
@ -547,7 +547,7 @@ async fn search_with_filter() {
|
||||
"balance": "$2,668.55",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lucas Hess",
|
||||
"gender": "male",
|
||||
"email": "lucashess@chorizon.com",
|
||||
@ -601,7 +601,7 @@ async fn search_with_filter() {
|
||||
"balance": "$1,913.42",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 24,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Emma Jacobs",
|
||||
"gender": "female",
|
||||
"email": "emmajacobs@chorizon.com",
|
||||
@ -705,7 +705,7 @@ async fn search_with_filter() {
|
||||
"balance": "$1,921.58",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -726,7 +726,7 @@ async fn search_with_filter() {
|
||||
"balance": "$2,668.55",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 36,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Lucas Hess",
|
||||
"gender": "male",
|
||||
"email": "lucashess@chorizon.com",
|
||||
@ -779,7 +779,7 @@ async fn search_with_filter() {
|
||||
"balance": "$1,351.43",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 28,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Evans Wagner",
|
||||
"gender": "male",
|
||||
"email": "evanswagner@chorizon.com",
|
||||
@ -823,7 +823,7 @@ async fn search_with_attributes_to_highlight_and_matches() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -843,7 +843,7 @@ async fn search_with_attributes_to_highlight_and_matches() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "<em>Cherry</em> Orr",
|
||||
"gender": "female",
|
||||
"email": "<em>cherry</em>orr@chorizon.com",
|
||||
@ -900,7 +900,7 @@ async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -920,7 +920,7 @@ async fn search_with_attributes_to_highlight_and_matches_and_crop() {
|
||||
"balance": "$1,706.13",
|
||||
"picture": "http://placehold.it/32x32",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -1223,7 +1223,7 @@ async fn test_faceted_search_valid() {
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.all(|value| value.get("color").unwrap() == "green"));
|
||||
.all(|value| value.get("color").unwrap() == "Green"));
|
||||
});
|
||||
|
||||
let query = json!({
|
||||
@ -1318,7 +1318,7 @@ async fn test_faceted_search_valid() {
|
||||
.unwrap() == "blue"
|
||||
|| value
|
||||
.get("color")
|
||||
.unwrap() == "green"));
|
||||
.unwrap() == "Green"));
|
||||
});
|
||||
// test and-or: ["tags:bug", ["color:blue", "color:green"]]
|
||||
let query = json!({
|
||||
@ -1345,7 +1345,7 @@ async fn test_faceted_search_valid() {
|
||||
.unwrap() == "blue"
|
||||
|| value
|
||||
.get("color")
|
||||
.unwrap() == "green")));
|
||||
.unwrap() == "Green")));
|
||||
|
||||
});
|
||||
}
|
||||
@ -1469,6 +1469,14 @@ async fn test_facet_count() {
|
||||
println!("{}", response);
|
||||
assert!(response.get("exhaustiveFacetsCount").is_some());
|
||||
assert_eq!(response.get("facetsDistribution").unwrap().as_object().unwrap().values().count(), 1);
|
||||
// assert that case is preserved
|
||||
assert!(response["facetsDistribution"]
|
||||
.as_object()
|
||||
.unwrap()["color"]
|
||||
.as_object()
|
||||
.unwrap()
|
||||
.get("Green")
|
||||
.is_some());
|
||||
});
|
||||
// searching on color and tags
|
||||
let query = json!({
|
||||
|
@ -130,7 +130,7 @@ async fn search_with_settings_stop_words() {
|
||||
{
|
||||
"balance": "$1,921.58",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -140,7 +140,7 @@ async fn search_with_settings_stop_words() {
|
||||
{
|
||||
"balance": "$1,706.13",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -213,7 +213,7 @@ async fn search_with_settings_synonyms() {
|
||||
{
|
||||
"balance": "$1,921.58",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -223,7 +223,7 @@ async fn search_with_settings_synonyms() {
|
||||
{
|
||||
"balance": "$1,706.13",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -292,7 +292,7 @@ async fn search_with_settings_ranking_rules() {
|
||||
{
|
||||
"balance": "$1,921.58",
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -302,7 +302,7 @@ async fn search_with_settings_ranking_rules() {
|
||||
{
|
||||
"balance": "$1,706.13",
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
@ -438,7 +438,7 @@ async fn search_with_settings_displayed_attributes() {
|
||||
let expect = json!([
|
||||
{
|
||||
"age": 31,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Harper Carson",
|
||||
"gender": "male",
|
||||
"email": "harpercarson@chorizon.com",
|
||||
@ -446,7 +446,7 @@ async fn search_with_settings_displayed_attributes() {
|
||||
},
|
||||
{
|
||||
"age": 27,
|
||||
"color": "green",
|
||||
"color": "Green",
|
||||
"name": "Cherry Orr",
|
||||
"gender": "female",
|
||||
"email": "cherryorr@chorizon.com",
|
||||
|
Loading…
Reference in New Issue
Block a user