From d8d29d3615b7dd68668cbb23a03b9a421d9b4763 Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 24 Sep 2020 16:39:42 +0200 Subject: [PATCH 1/2] Revert "fix facet count bug" This reverts commit 733c02dd7c7b34265f07b4106b53d1a5eb873da2. --- meilisearch-core/src/bucket_sort.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/meilisearch-core/src/bucket_sort.rs b/meilisearch-core/src/bucket_sort.rs index 6c9b87301..f0fc71bd0 100644 --- a/meilisearch-core/src/bucket_sort.rs +++ b/meilisearch-core/src/bucket_sort.rs @@ -100,12 +100,6 @@ where debug!("found {} documents", docids.len()); debug!("number of postings {:?}", queries.len()); - if let Some(f) = facet_count_docids { - // hardcoded value, until approximation optimization - result.exhaustive_facets_count = Some(true); - result.facets = Some(facet_count(f, &docids)); - } - if let Some(facets_docids) = facets_docids { let intersection = sdset::duo::OpBuilder::new(docids.as_ref(), facets_docids.as_set()) .intersection() @@ -113,6 +107,12 @@ where docids = Cow::Owned(intersection); } + if let Some(f) = facet_count_docids { + // hardcoded value, until approximation optimization + result.exhaustive_facets_count = Some(true); + result.facets = Some(facet_count(f, &docids)); + } + let before = Instant::now(); mk_arena!(arena); let mut bare_matches = cleanup_bare_matches(&mut arena, &docids, queries); @@ -243,12 +243,6 @@ where debug!("found {} documents", docids.len()); debug!("number of postings {:?}", queries.len()); - if let Some(f) = facet_count_docids { - // hardcoded value, until approximation optimization - result.exhaustive_facets_count = Some(true); - result.facets = Some(facet_count(f, &docids)); - } - if let Some(facets_docids) = facets_docids { let intersection = OpBuilder::new(docids.as_ref(), facets_docids.as_set()) .intersection() @@ -256,6 +250,12 @@ where docids = Cow::Owned(intersection); } + if let Some(f) = facet_count_docids { + // hardcoded value, until approximation optimization + result.exhaustive_facets_count = Some(true); + result.facets = Some(facet_count(f, &docids)); + } + let before = Instant::now(); mk_arena!(arena); let mut bare_matches = cleanup_bare_matches(&mut arena, &docids, queries); From 030bcd8b05acf0f6cd9a8fd46bc79778b6bf79a1 Mon Sep 17 00:00:00 2001 From: mpostma Date: Thu, 24 Sep 2020 16:40:18 +0200 Subject: [PATCH 2/2] Revert "facet count more tests" This reverts commit 954f572e79c63e9b594cbda39597e3673d478aec. --- meilisearch-http/tests/search.rs | 35 +------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/meilisearch-http/tests/search.rs b/meilisearch-http/tests/search.rs index 18d0139bd..450e99794 100644 --- a/meilisearch-http/tests/search.rs +++ b/meilisearch-http/tests/search.rs @@ -1466,6 +1466,7 @@ async fn test_facet_count() { server.update_all_settings(body).await; // same as before, but now facets are set: test_post_get_search!(server, query, |response, _status_code|{ + 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 @@ -1695,37 +1696,3 @@ async fn update_documents_with_facet_distribution() { let (response2, _) = server.search_post(search).await; assert_json_eq!(expected_facet_distribution, response2["facetsDistribution"].clone()); } - -#[actix_rt::test] -async fn test_facet_count_with_facet_filter() { - let mut server = common::Server::test_server().await; - let body = json!({ - "attributesForFaceting": ["gender"] - }); - server.update_all_settings(body).await; - let query = json!({ - "q": "a", - "facetsDistribution": ["gender"], - "facetFilters": ["gender:male"], - }); - - test_post_get_search!(server, query, |response, _status_code|{ - assert!(response.get("exhaustiveFacetsCount").is_some()); - let facets_distribution = response.get("facetsDistribution").unwrap().as_object(); - assert_eq!(facets_distribution.unwrap()["gender"]["male"], 37); - assert_eq!(facets_distribution.unwrap()["gender"]["female"], 39); - }); - // facet distribution should remain the same when facet filter changes - let query = json!({ - "q": "a", - "facetsDistribution": ["gender"], - "facetFilters": [["gender:male", "gender:female"]], - }); - - test_post_get_search!(server, query, |response, _status_code|{ - assert!(response.get("exhaustiveFacetsCount").is_some()); - let facets_distribution = response.get("facetsDistribution").unwrap().as_object(); - assert_eq!(facets_distribution.unwrap()["gender"]["male"], 37); - assert_eq!(facets_distribution.unwrap()["gender"]["female"], 39); - }); -}