uqa_execution/query/retrieval/
context.rs1use uqa_core::{DocId, ScoredEntry};
10use uqa_scoring::{BayesianBM25Params, ScoringMode};
11use uqa_sql::{expr::EngineHook, semantics::text_indexes::TextMatchCatalog, SQLError};
12use uqa_storage::document_store::Document;
13
14pub trait TextRetrieval {
15 fn bayesian_params(&self, table: &str, field: &str) -> Result<BayesianBM25Params, SQLError>;
16 fn search(
17 &self,
18 table: &str,
19 field: &str,
20 query: &str,
21 mode: &ScoringMode,
22 top_k: usize,
23 ) -> Result<Vec<ScoredEntry>, SQLError>;
24}
25
26pub trait RetrievalDocuments {
27 fn get_document(&self, table: &str, doc_id: DocId) -> Result<Option<Document>, SQLError>;
28}
29
30pub trait VectorPoolRetrieval {
31 fn query_pool(
32 &self,
33 table: &str,
34 field: &str,
35 query_vector: &[f32],
36 k: usize,
37 diagnostics: Option<&crate::query::diagnostics::CapturedDiagnostics>,
38 ) -> Result<Vec<ScoredEntry>, SQLError>;
39}
40
41#[derive(Clone, Copy)]
42pub struct TextRetrievalContext<'a> {
43 pub catalog: &'a dyn TextMatchCatalog,
44 pub text: &'a dyn TextRetrieval,
45 pub functions: &'a dyn EngineHook,
46}