You've already forked AstralRinth
forked from didirus/AstralRinth
Fix search
This commit is contained in:
@@ -162,9 +162,9 @@ pub async fn index_local(pool: PgPool) -> Result<Vec<UploadSearchMod>, IndexingE
|
||||
date_modified: mod_data.updated,
|
||||
modified_timestamp: mod_data.updated.timestamp(),
|
||||
latest_version,
|
||||
license: Some(license.short),
|
||||
client_side: Some(client_side.to_string()),
|
||||
server_side: Some(server_side.to_string()),
|
||||
license: license.short,
|
||||
client_side: client_side.to_string(),
|
||||
server_side: server_side.to_string(),
|
||||
host: Cow::Borrowed("modrinth"),
|
||||
slug: mod_data.slug,
|
||||
});
|
||||
@@ -311,9 +311,9 @@ pub async fn query_one(
|
||||
date_modified: mod_data.updated,
|
||||
modified_timestamp: mod_data.updated.timestamp(),
|
||||
latest_version,
|
||||
license: Some(license.short),
|
||||
client_side: Some(client_side.to_string()),
|
||||
server_side: Some(server_side.to_string()),
|
||||
license: license.short,
|
||||
client_side: client_side.to_string(),
|
||||
server_side: server_side.to_string(),
|
||||
host: Cow::Borrowed("modrinth"),
|
||||
slug: mod_data.slug,
|
||||
})
|
||||
|
||||
@@ -76,6 +76,7 @@ pub async fn reset_indices(config: &SearchConfig) -> Result<(), IndexingError> {
|
||||
|
||||
client.delete_index("relevance_mods").await?;
|
||||
client.delete_index("downloads_mods").await?;
|
||||
client.delete_index("follows_mods").await?;
|
||||
client.delete_index("updated_mods").await?;
|
||||
client.delete_index("newest_mods").await?;
|
||||
Ok(())
|
||||
@@ -207,6 +208,15 @@ pub async fn add_mods(
|
||||
.await?;
|
||||
add_to_index(downloads_index, &mods).await?;
|
||||
|
||||
// Follows Index
|
||||
let follows_index = create_index(&client, "follows_mods", || {
|
||||
let mut follows_rules = default_rules();
|
||||
follows_rules.push_front("desc(follows)".to_string());
|
||||
follows_rules.into()
|
||||
})
|
||||
.await?;
|
||||
add_to_index(follows_index, &mods).await?;
|
||||
|
||||
// Updated Index
|
||||
let updated_index = create_index(&client, "updated_mods", || {
|
||||
let mut updated_rules = default_rules();
|
||||
@@ -244,6 +254,7 @@ fn default_rules() -> VecDeque<String> {
|
||||
fn default_settings() -> Settings {
|
||||
let displayed_attributes = vec![
|
||||
"mod_id".to_string(),
|
||||
"slug".to_string(),
|
||||
"author".to_string(),
|
||||
"title".to_string(),
|
||||
"description".to_string(),
|
||||
@@ -257,6 +268,9 @@ fn default_settings() -> Settings {
|
||||
"date_created".to_string(),
|
||||
"date_modified".to_string(),
|
||||
"latest_version".to_string(),
|
||||
"license".to_string(),
|
||||
"client_side".to_string(),
|
||||
"server_side".to_string(),
|
||||
"host".to_string(),
|
||||
];
|
||||
|
||||
@@ -268,11 +282,14 @@ fn default_settings() -> Settings {
|
||||
"author".to_string(),
|
||||
];
|
||||
|
||||
let stop_words: Vec<String> = Vec::new();
|
||||
let synonyms: HashMap<String, Vec<String>> = HashMap::new();
|
||||
|
||||
Settings::new()
|
||||
.with_displayed_attributes(displayed_attributes)
|
||||
.with_searchable_attributes(searchable_attributes)
|
||||
.with_stop_words(vec![])
|
||||
.with_synonyms(HashMap::new())
|
||||
.with_stop_words(stop_words)
|
||||
.with_synonyms(synonyms)
|
||||
.with_attributes_for_faceting(vec![
|
||||
String::from("categories"),
|
||||
String::from("host"),
|
||||
|
||||
@@ -74,9 +74,9 @@ pub struct UploadSearchMod {
|
||||
pub icon_url: String,
|
||||
pub author_url: String,
|
||||
pub latest_version: Cow<'static, str>,
|
||||
pub license: Option<String>,
|
||||
pub client_side: Option<String>,
|
||||
pub server_side: Option<String>,
|
||||
pub license: String,
|
||||
pub client_side: String,
|
||||
pub server_side: String,
|
||||
|
||||
/// RFC 3339 formatted creation date of the mod
|
||||
pub date_created: DateTime<Utc>,
|
||||
@@ -109,6 +109,7 @@ pub struct ResultSearchMod {
|
||||
// TODO: more efficient format for listing versions, without many repetitions
|
||||
pub versions: Vec<String>,
|
||||
pub downloads: i32,
|
||||
pub follows: i32,
|
||||
pub page_url: String,
|
||||
pub icon_url: String,
|
||||
pub author_url: String,
|
||||
@@ -117,9 +118,9 @@ pub struct ResultSearchMod {
|
||||
/// RFC 3339 formatted modification date of the mod
|
||||
pub date_modified: String,
|
||||
pub latest_version: String,
|
||||
pub license: Option<String>,
|
||||
pub client_side: Option<String>,
|
||||
pub server_side: Option<String>,
|
||||
pub license: String,
|
||||
pub client_side: String,
|
||||
pub server_side: String,
|
||||
|
||||
/// The host of the mod: Either `modrinth` or `curseforge`
|
||||
pub host: String,
|
||||
|
||||
Reference in New Issue
Block a user