feat: extensible search engine with person entities (FTS5/tsvector)

This commit is contained in:
2026-05-12 18:45:24 +02:00
parent 763d622601
commit c6770659c5
45 changed files with 2421 additions and 86 deletions

View File

@@ -3,8 +3,8 @@ use std::sync::Arc;
use anyhow::Context;
use domain::ports::{
DiaryRepository, ImageRefCommand, ImageRefQuery, ImportProfileRepository,
ImportSessionRepository, MovieProfileRepository, MovieRepository, ReviewRepository,
StatsRepository, UserRepository,
ImportSessionRepository, MovieProfileRepository, MovieRepository, PersonCommand, PersonQuery,
ReviewRepository, SearchCommand, SearchPort, StatsRepository, UserRepository,
};
pub enum DbPool {
@@ -24,7 +24,11 @@ pub struct Repos {
pub import_profile: Arc<dyn ImportProfileRepository>,
pub movie_profile: Arc<dyn MovieProfileRepository>,
pub image_ref_command: Arc<dyn ImageRefCommand>,
pub image_ref_query: Arc<dyn ImageRefQuery>,
pub image_ref_query: Arc<dyn ImageRefQuery>,
pub person_command: Arc<dyn PersonCommand>,
pub person_query: Arc<dyn PersonQuery>,
pub search_command: Arc<dyn SearchCommand>,
pub search_port: Arc<dyn SearchPort>,
}
pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<(Repos, DbPool)> {
@@ -34,18 +38,26 @@ pub async fn connect(database_url: &str, backend: &str) -> anyhow::Result<(Repos
let (pool, m, r, d, s, u, is, ip, mp) =
postgres::wire(database_url).await.context("PostgreSQL connection failed")?;
let (image_ref_command, image_ref_query) = postgres::create_image_ref(pool.clone());
let (person_command, person_query) = postgres::create_person_adapter(pool.clone());
let (search_command, search_port) = postgres_search::create_search_adapter(pool.clone());
Ok((Repos { movie: m, review: r, diary: d, stats: s, user: u,
import_session: is, import_profile: ip, movie_profile: mp,
image_ref_command, image_ref_query }, DbPool::Postgres(pool)))
image_ref_command, image_ref_query,
person_command, person_query, search_command, search_port },
DbPool::Postgres(pool)))
}
#[cfg(feature = "sqlite")]
_ => {
let (pool, m, r, d, s, u, is, ip, mp) =
sqlite::wire(database_url).await.context("SQLite connection failed")?;
let (image_ref_command, image_ref_query) = sqlite::create_image_ref(pool.clone());
let (person_command, person_query) = sqlite::create_person_adapter(pool.clone());
let (search_command, search_port) = sqlite_search::create_search_adapter(pool.clone());
Ok((Repos { movie: m, review: r, diary: d, stats: s, user: u,
import_session: is, import_profile: ip, movie_profile: mp,
image_ref_command, image_ref_query }, DbPool::Sqlite(pool)))
image_ref_command, image_ref_query,
person_command, person_query, search_command, search_port },
DbPool::Sqlite(pool)))
}
#[cfg(not(feature = "sqlite"))]
_ => anyhow::bail!("DATABASE_BACKEND={backend} is not supported by this build"),