re-modularizes-search-facets (#842)

Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Wyatt Verchere
2024-01-12 08:05:46 -08:00
committed by GitHub
parent ef31c0c0da
commit 4483bb147c

View File

@@ -293,27 +293,39 @@ async fn update_and_add_to_index(
client: &Client, client: &Client,
index: &Index, index: &Index,
projects: &[UploadSearchProject], projects: &[UploadSearchProject],
_additional_fields: &[String], additional_fields: &[String],
) -> Result<(), IndexingError> { ) -> Result<(), IndexingError> {
// TODO: Uncomment this- hardcoding loader_fields is a band-aid fix, and will be fixed soon // TODO: Uncomment this- hardcoding loader_fields is a band-aid fix, and will be fixed soon
// let mut new_filterable_attributes: Vec<String> = index.get_filterable_attributes().await?; let mut new_filterable_attributes: Vec<String> = index.get_filterable_attributes().await?;
// let mut new_displayed_attributes = index.get_displayed_attributes().await?; let mut new_displayed_attributes = index.get_displayed_attributes().await?;
// new_filterable_attributes.extend(additional_fields.iter().map(|s: &String| s.to_string())); // Check if any 'additional_fields' are not already in the index
// new_displayed_attributes.extend(additional_fields.iter().map(|s| s.to_string())); // Only add if they are not already in the index
// info!("add attributes."); let new_fields = additional_fields
// let filterable_task = index .into_iter()
// .set_filterable_attributes(new_filterable_attributes) .filter(|x| !new_filterable_attributes.contains(x))
// .await?; .collect::<Vec<_>>();
// let displayable_task = index if !new_fields.is_empty() {
// .set_displayed_attributes(new_displayed_attributes) info!("Adding new fields to index: {:?}", new_fields);
// .await?; new_filterable_attributes.extend(new_fields.iter().map(|s: &&String| s.to_string()));
// filterable_task new_displayed_attributes.extend(new_fields.iter().map(|s| s.to_string()));
// .wait_for_completion(client, None, Some(TIMEOUT))
// .await?; // Adds new fields to the index
// displayable_task let filterable_task = index
// .wait_for_completion(client, None, Some(TIMEOUT)) .set_filterable_attributes(new_filterable_attributes)
// .await?; .await?;
let displayable_task = index
.set_displayed_attributes(new_displayed_attributes)
.await?;
// Allow a long timeout for adding new attributes- it only needs to happen the once
filterable_task
.wait_for_completion(client, None, Some(TIMEOUT * 100))
.await?;
displayable_task
.wait_for_completion(client, None, Some(TIMEOUT * 100))
.await?;
}
info!("Adding to index."); info!("Adding to index.");
@@ -374,14 +386,6 @@ const DEFAULT_DISPLAYED_ATTRIBUTES: &[&str] = &[
"gallery", "gallery",
"featured_gallery", "featured_gallery",
"color", "color",
// Note: loader fields are not here, but are added on as they are needed (so they can be dynamically added depending on which exist).
// TODO: remove these- as they should be automatically populated. This is a band-aid fix.
"server_only",
"client_only",
"game_versions",
"singleplayer",
"client_and_server",
"mrpack_loaders",
// V2 legacy fields for logical consistency // V2 legacy fields for logical consistency
"client_side", "client_side",
"server_side", "server_side",
@@ -420,14 +424,6 @@ const DEFAULT_ATTRIBUTES_FOR_FACETING: &[&str] = &[
"project_id", "project_id",
"open_source", "open_source",
"color", "color",
// Note: loader fields are not here, but are added on as they are needed (so they can be dynamically added depending on which exist).
// TODO: remove these- as they should be automatically populated. This is a band-aid fix.
"server_only",
"client_only",
"game_versions",
"singleplayer",
"client_and_server",
"mrpack_loaders",
// V2 legacy fields for logical consistency // V2 legacy fields for logical consistency
"client_side", "client_side",
"server_side", "server_side",