update tests for facets distribution case

This commit is contained in:
mpostma
2020-06-26 12:59:46 +02:00
parent 18a50b4dac
commit afacdbc7a0
6 changed files with 75 additions and 67 deletions

View File

@@ -636,7 +636,7 @@ pub fn placeholder_document_sort(
}
/// For each entry in facet_docids, calculates the number of documents in the intersection with candidate_docids.
fn facet_count(
pub fn facet_count(
facet_docids: HashMap<String, HashMap<String, (&str, Cow<Set<DocumentId>>)>>,
candidate_docids: &Set<DocumentId>,
) -> HashMap<String, HashMap<String, usize>> {

View File

@@ -204,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();

View File

@@ -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",

View File

@@ -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")));
});
}

View File

@@ -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!({

View File

@@ -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",