use khive_score::DeterministicScore;
use uuid::Uuid;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RankScoreKind {
Rrf,
Vector,
Keyword,
Weighted,
Union,
}
impl RankScoreKind {
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Rrf => "rrf",
Self::Vector => "vector",
Self::Keyword => "keyword",
Self::Weighted => "weighted",
Self::Union => "union",
}
}
}
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct SearchSignals {
pub vector_similarity: Option<DeterministicScore>,
pub keyword_score: Option<DeterministicScore>,
}
#[derive(Clone, Debug)]
pub struct SearchHit {
pub entity_id: Uuid,
pub score: DeterministicScore,
pub rank_score_kind: RankScoreKind,
pub signals: SearchSignals,
pub source: SearchSource,
pub title: Option<String>,
pub snippet: Option<String>,
}
#[derive(Clone, Debug)]
pub struct HybridSearchOutcome {
pub hits: Vec<SearchHit>,
pub vector_error: Option<String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SearchSource {
Vector,
Text,
Both,
}
impl SearchSource {
#[must_use]
pub const fn union(self, other: Self) -> Self {
match (self, other) {
(Self::Text, Self::Text) => Self::Text,
(Self::Vector, Self::Vector) => Self::Vector,
_ => Self::Both,
}
}
#[must_use]
pub const fn as_str(self) -> &'static str {
match self {
Self::Vector => "vector",
Self::Text => "text",
Self::Both => "both",
}
}
}