Search fixes (#62)

This commit is contained in:
Geometrically 2020-09-12 18:16:05 -07:00 committed by GitHub
parent e8bbc117e1
commit 88c0b8a8f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 205 additions and 256 deletions

5
.env
View File

@ -15,7 +15,8 @@ BACKBLAZE_KEY=none
BACKBLAZE_BUCKET_ID=none BACKBLAZE_BUCKET_ID=none
INDEX_CURSEFORGE=false INDEX_CURSEFORGE=false
MAX_CURSEFORGE_ID=450000
# 1 hour # 1 hour
LOCAL_INDEX_INTERVAL=3600 LOCAL_INDEX_INTERVAL=3600
# 4 hours # 12 hours
EXTERNAL_INDEX_INTERVAL=14400 EXTERNAL_INDEX_INTERVAL=43200

444
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -149,7 +149,7 @@ async fn main() -> std::io::Result<()> {
dotenv::var("EXTERNAL_INDEX_INTERVAL") dotenv::var("EXTERNAL_INDEX_INTERVAL")
.ok() .ok()
.map(|i| i.parse().unwrap()) .map(|i| i.parse().unwrap())
.unwrap_or(3600 * 4), .unwrap_or(3600 * 12),
); );
let pool_ref = pool.clone(); let pool_ref = pool.clone();
@ -242,6 +242,7 @@ fn check_env_vars() {
.unwrap_or(false) .unwrap_or(false)
{ {
check_var::<usize>("EXTERNAL_INDEX_INTERVAL"); check_var::<usize>("EXTERNAL_INDEX_INTERVAL");
check_var::<usize>("MAX_CURSEFORGE_ID");
} }
check_var::<usize>("LOCAL_INDEX_INTERVAL"); check_var::<usize>("LOCAL_INDEX_INTERVAL");

View File

@ -62,7 +62,12 @@ pub async fn index_mods(pool: PgPool, settings: IndexingSettings) -> Result<(),
docs_to_add.append(&mut index_local(pool.clone()).await?); docs_to_add.append(&mut index_local(pool.clone()).await?);
} }
if settings.index_external { if settings.index_external {
docs_to_add.append(&mut index_curseforge(1, 400_000).await?); let end_index = dotenv::var("MAX_CURSEFORGE_ID")
.ok()
.map(|i| i.parse().unwrap())
.unwrap_or(450_000);
docs_to_add.append(&mut index_curseforge(1, end_index).await?);
} }
// Write Indices // Write Indices
@ -266,7 +271,7 @@ fn default_settings() -> Settings {
.with_searchable_attributes(searchable_attributes) .with_searchable_attributes(searchable_attributes)
.with_stop_words(vec![]) .with_stop_words(vec![])
.with_synonyms(HashMap::new()) .with_synonyms(HashMap::new())
.with_attributes_for_faceting(vec![String::from("categories"), String::from("host")]) .with_attributes_for_faceting(vec![String::from("categories"), String::from("host"), String::from("versions")])
} }
//endregion //endregion