You've already forked AstralRinth
forked from didirus/AstralRinth
Add alphabetically sorting (#190)
This commit is contained in:
@@ -77,6 +77,7 @@ pub async fn reset_indices(config: &SearchConfig) -> Result<(), IndexingError> {
|
|||||||
client.delete_index("relevance_mods").await?;
|
client.delete_index("relevance_mods").await?;
|
||||||
client.delete_index("downloads_mods").await?;
|
client.delete_index("downloads_mods").await?;
|
||||||
client.delete_index("follows_mods").await?;
|
client.delete_index("follows_mods").await?;
|
||||||
|
client.delete_index("alphabetically_mods").await?;
|
||||||
client.delete_index("updated_mods").await?;
|
client.delete_index("updated_mods").await?;
|
||||||
client.delete_index("newest_mods").await?;
|
client.delete_index("newest_mods").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -109,6 +110,14 @@ pub async fn reconfigure_indices(config: &SearchConfig) -> Result<(), IndexingEr
|
|||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
// Alphabetically Index
|
||||||
|
update_index(&client, "alphabetically_mods", {
|
||||||
|
let mut alphabetically_rules = default_rules();
|
||||||
|
alphabetically_rules.push_front("desc(title)".to_string());
|
||||||
|
alphabetically_rules.into()
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Updated Index
|
// Updated Index
|
||||||
update_index(&client, "updated_mods", {
|
update_index(&client, "updated_mods", {
|
||||||
let mut updated_rules = default_rules();
|
let mut updated_rules = default_rules();
|
||||||
@@ -217,6 +226,15 @@ pub async fn add_mods(
|
|||||||
.await?;
|
.await?;
|
||||||
add_to_index(follows_index, &mods).await?;
|
add_to_index(follows_index, &mods).await?;
|
||||||
|
|
||||||
|
// Alphabetically Index
|
||||||
|
let alphabetically_index = create_index(&client, "alphabetically_mods", || {
|
||||||
|
let mut alphabetically_rules = default_rules();
|
||||||
|
alphabetically_rules.push_front("desc(title)".to_string());
|
||||||
|
alphabetically_rules.into()
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
add_to_index(alphabetically_index, &mods).await?;
|
||||||
|
|
||||||
// Updated Index
|
// Updated Index
|
||||||
let updated_index = create_index(&client, "updated_mods", || {
|
let updated_index = create_index(&client, "updated_mods", || {
|
||||||
let mut updated_rules = default_rules();
|
let mut updated_rules = default_rules();
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ pub async fn search_for_mod(
|
|||||||
"relevance" => "relevance_mods",
|
"relevance" => "relevance_mods",
|
||||||
"downloads" => "downloads_mods",
|
"downloads" => "downloads_mods",
|
||||||
"follows" => "follows_mods",
|
"follows" => "follows_mods",
|
||||||
|
"alphabetically" => "alphabetically_mods",
|
||||||
"updated" => "updated_mods",
|
"updated" => "updated_mods",
|
||||||
"newest" => "newest_mods",
|
"newest" => "newest_mods",
|
||||||
i => return Err(SearchError::InvalidIndex(i.to_string())),
|
i => return Err(SearchError::InvalidIndex(i.to_string())),
|
||||||
|
|||||||
Reference in New Issue
Block a user