Search backend refactor with typesense impl (#5528)
* initial elasticsearch impl * working elastic cluster * replace SearchError with ApiError for preparation of search backend * start factoring meili out to trait * move meili to backend * update routes to use search backend trait * wip * Update projects.rs * search backend is only init'd once in config * wip * wip: backend agnostic * change search internal routes to delegate to backend * initial elasticsearch impl * fix filtering * elastic impl * refactor indexing into its own module * clean up elastic code * fix ci * fix tests * fix elastic health check * fix up env rebase * fix compile * dummy commit to update github pr * Fix rebase * Elastic basic https auth * Fix duplicate projects showing up * Fix up tests * Replace search `ApiErrors` with `eyre::Reports`, propagate background task errors * clean up agents files * make index chunk size configurable * make `match_phrase` in elastic case-insensitive * use current/next indices and swap between them * test case for error body * Fix failing case * da merge * factor out common stuff from search backends * allow fetching hit metadata from search results * allow customising elasticsearch search config * bit of docs * add mappings to indices for elastic * Implement Typesense * wip * fix up some sort fields stuff * use different approach to filterable field sets * remove a bunch of search fields which weren't used for filtering * bucket text matches * Bucketing by text_match for typesense * fix tombi lint * fix some sentry errors and dont prioritise 2+ term matches * tweak ts query settings * expose some more search settings * query sort changes * small fixes * should fix pagination stuff * fix healthcheck maybe * ragebait ci * tests * tests * revert environment
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
use crate::database;
|
||||
use crate::database::PgPool;
|
||||
use crate::database::redis::RedisPool;
|
||||
use crate::queue::analytics::cache::cache_analytics;
|
||||
@@ -8,9 +9,9 @@ use crate::queue::payouts::{
|
||||
insert_bank_balances_and_webhook, process_affiliate_payouts,
|
||||
process_payout, remove_payouts_for_refunded_charges,
|
||||
};
|
||||
use crate::search::indexing::index_projects;
|
||||
use crate::search::SearchBackend;
|
||||
use crate::util::anrok;
|
||||
use crate::{database, search};
|
||||
use actix_web::web;
|
||||
use clap::ValueEnum;
|
||||
use eyre::WrapErr;
|
||||
use tracing::info;
|
||||
@@ -42,7 +43,7 @@ impl BackgroundTask {
|
||||
pool: PgPool,
|
||||
ro_pool: PgPool,
|
||||
redis_pool: RedisPool,
|
||||
search_config: search::SearchConfig,
|
||||
search_backend: web::Data<dyn SearchBackend>,
|
||||
clickhouse: clickhouse::Client,
|
||||
stripe_client: stripe::Client,
|
||||
anrok_client: anrok::Client,
|
||||
@@ -53,7 +54,7 @@ impl BackgroundTask {
|
||||
match self {
|
||||
Migrations => run_migrations().await,
|
||||
IndexSearch => {
|
||||
index_search(ro_pool, redis_pool, search_config).await
|
||||
index_search(ro_pool, redis_pool, search_backend).await
|
||||
}
|
||||
ReleaseScheduled => release_scheduled(pool).await,
|
||||
UpdateVersions => update_versions(pool, redis_pool).await,
|
||||
@@ -132,10 +133,10 @@ pub async fn run_migrations() -> eyre::Result<()> {
|
||||
pub async fn index_search(
|
||||
ro_pool: PgPool,
|
||||
redis_pool: RedisPool,
|
||||
search_config: search::SearchConfig,
|
||||
search_backend: web::Data<dyn SearchBackend>,
|
||||
) -> eyre::Result<()> {
|
||||
info!("Indexing local database");
|
||||
index_projects(ro_pool, redis_pool, &search_config).await
|
||||
search_backend.index_projects(ro_pool, redis_pool).await
|
||||
}
|
||||
|
||||
pub async fn release_scheduled(pool: PgPool) -> eyre::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user