Fix PR comments

This commit is contained in:
ManyTheFish 2024-11-26 15:53:54 +01:00
parent f014e78684
commit 2e896f30a5
4 changed files with 54 additions and 57 deletions

View File

@ -41,8 +41,8 @@ async fn simple_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -65,8 +65,8 @@ async fn advanced_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "enabled": false })).await; index.update_settings_typo_tolerance(json!({ "enabled": false })).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
@ -89,8 +89,8 @@ async fn more_advanced_facet_search() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await; index.update_settings_typo_tolerance(json!({ "disableOnWords": ["adventre"] })).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "adventre"})).await;
@ -113,8 +113,8 @@ async fn simple_facet_search_with_max_values() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await; index.update_settings_faceting(json!({ "maxValuesPerFacet": 1 })).await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -135,8 +135,8 @@ async fn simple_facet_search_by_count_with_max_values() {
) )
.await; .await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -151,8 +151,8 @@ async fn non_filterable_facet_search_error() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(0).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -170,8 +170,8 @@ async fn facet_search_dont_support_words() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "words"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "words"})).await;
@ -188,8 +188,8 @@ async fn simple_facet_search_with_sort_by_count() {
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.update_settings_faceting(json!({ "sortFacetValuesBy": { "*": "count" } })).await; index.update_settings_faceting(json!({ "sortFacetValuesBy": { "*": "count" } })).await;
index.update_settings_filterable_attributes(json!(["genres"])).await; index.update_settings_filterable_attributes(json!(["genres"])).await;
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -207,8 +207,8 @@ async fn add_documents_and_deactivate_facet_search() {
let index = server.index("test"); let index = server.index("test");
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(0).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
"facetSearch": false, "facetSearch": false,
@ -216,7 +216,7 @@ async fn add_documents_and_deactivate_facet_search() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -237,10 +237,10 @@ async fn deactivate_facet_search_and_add_documents() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -261,10 +261,10 @@ async fn deactivate_facet_search_add_documents_and_activate_facet_search() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
@ -272,7 +272,7 @@ async fn deactivate_facet_search_add_documents_and_activate_facet_search() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;
@ -293,10 +293,10 @@ async fn deactivate_facet_search_add_documents_and_reset_facet_search() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
let documents = DOCUMENTS.clone(); let documents = DOCUMENTS.clone();
index.add_documents(documents, None).await; let (response, _code) = index.add_documents(documents, None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
@ -304,7 +304,7 @@ async fn deactivate_facet_search_add_documents_and_reset_facet_search() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(2).await; index.wait_task(response.uid()).await;
let (response, code) = let (response, code) =
index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await; index.facet_search(json!({"facetName": "genres", "facetQuery": "a"})).await;

View File

@ -29,8 +29,8 @@ async fn add_docs_and_disable() {
let server = Server::new().await; let server = Server::new().await;
let index = server.index("test"); let index = server.index("test");
index.add_documents(DOCUMENTS.clone(), None).await; let (response, _code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(0).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
@ -39,7 +39,7 @@ async fn add_docs_and_disable() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(1).await; index.wait_task(response.uid()).await;
// only 1 document should match // only 1 document should match
index index
@ -96,10 +96,10 @@ async fn disable_and_add_docs() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
index.add_documents(DOCUMENTS.clone(), None).await; let (response, _code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
// only 1 document should match // only 1 document should match
index index
@ -155,10 +155,10 @@ async fn disable_add_docs_and_enable() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
index.add_documents(DOCUMENTS.clone(), None).await; let (response, _code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
@ -263,10 +263,10 @@ async fn disable_add_docs_and_reset() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
index.add_documents(DOCUMENTS.clone(), None).await; let (response, _code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
let (response, code) = index let (response, code) = index
.update_settings(json!({ .update_settings(json!({
@ -370,10 +370,10 @@ async fn default_behavior() {
})) }))
.await; .await;
assert_eq!("202", code.as_str(), "{:?}", response); assert_eq!("202", code.as_str(), "{:?}", response);
index.wait_task(0).await; index.wait_task(response.uid()).await;
index.add_documents(DOCUMENTS.clone(), None).await; let (response, _code) = index.add_documents(DOCUMENTS.clone(), None).await;
index.wait_task(1).await; index.wait_task(response.uid()).await;
// all documents should match // all documents should match
index index

View File

@ -1690,11 +1690,7 @@ impl Index {
pub fn prefix_settings(&self, rtxn: &RoTxn<'_>) -> Result<PrefixSettings> { pub fn prefix_settings(&self, rtxn: &RoTxn<'_>) -> Result<PrefixSettings> {
let compute_prefixes = self.prefix_search(rtxn)?.unwrap_or_default(); let compute_prefixes = self.prefix_search(rtxn)?.unwrap_or_default();
Ok(PrefixSettings { Ok(PrefixSettings { compute_prefixes, max_prefix_length: 4, prefix_count_threshold: 100 })
compute_prefixes,
max_prefix_length: 4,
prefix_count_threshold: 100,
})
} }
} }

View File

@ -172,14 +172,15 @@ impl<'i> FacetsUpdate<'i> {
incremental_update.execute(wtxn)?; incremental_update.execute(wtxn)?;
} }
match self.normalized_delta_data { if !self.index.facet_search(wtxn)? {
_ if !self.index.facet_search(wtxn)? => {
// If facet search is disabled, we don't need to compute facet search databases. // If facet search is disabled, we don't need to compute facet search databases.
// We clear the facet search databases. // We clear the facet search databases.
self.index.facet_id_string_fst.clear(wtxn)?; self.index.facet_id_string_fst.clear(wtxn)?;
self.index.facet_id_normalized_string_strings.clear(wtxn)?; self.index.facet_id_normalized_string_strings.clear(wtxn)?;
Ok(()) return Ok(());
} }
match self.normalized_delta_data {
Some(data) => index_facet_search(wtxn, data, self.index), Some(data) => index_facet_search(wtxn, data, self.index),
None => Ok(()), None => Ok(()),
} }