pub struct HybridSearchEngine { /* private fields */ }Expand description
HybridSearchEngine - Orchestrates semantic and keyword search
Features:
- Combines VectorSearchEngine (semantic) and KeywordSearchEngine (keyword)
- Score fusion using Reciprocal Rank Fusion (RRF)
- Metadata filtering for event_type, entity_id, and time range
- Configurable search modes and weights
Implementations§
Source§impl HybridSearchEngine
impl HybridSearchEngine
Sourcepub fn new(
vector_engine: Arc<VectorSearchEngine>,
keyword_engine: Arc<KeywordSearchEngine>,
) -> Self
pub fn new( vector_engine: Arc<VectorSearchEngine>, keyword_engine: Arc<KeywordSearchEngine>, ) -> Self
Create a new HybridSearchEngine with existing engines
Sourcepub fn with_config(
vector_engine: Arc<VectorSearchEngine>,
keyword_engine: Arc<KeywordSearchEngine>,
config: HybridSearchEngineConfig,
) -> Self
pub fn with_config( vector_engine: Arc<VectorSearchEngine>, keyword_engine: Arc<KeywordSearchEngine>, config: HybridSearchEngineConfig, ) -> Self
Create a new HybridSearchEngine with custom configuration
Sourcepub fn config(&self) -> &HybridSearchEngineConfig
pub fn config(&self) -> &HybridSearchEngineConfig
Get the engine configuration
Sourcepub fn store_metadata(&self, event_id: Uuid, metadata: EventMetadata)
pub fn store_metadata(&self, event_id: Uuid, metadata: EventMetadata)
Store metadata for an event (for post-search filtering)
Sourcepub async fn index_event(
&self,
event_id: Uuid,
_tenant_id: &str,
event_type: &str,
entity_id: Option<&str>,
_payload: &Value,
timestamp: DateTime<Utc>,
) -> Result<()>
pub async fn index_event( &self, event_id: Uuid, _tenant_id: &str, event_type: &str, entity_id: Option<&str>, _payload: &Value, timestamp: DateTime<Utc>, ) -> Result<()>
Stub for when features are not enabled
pub fn commit(&self) -> Result<()>
Sourcepub fn search(&self, query: &SearchQuery) -> Result<Vec<HybridSearchResult>>
pub fn search(&self, query: &SearchQuery) -> Result<Vec<HybridSearchResult>>
Perform a search using the configured mode
This is the main entry point for searching. It:
- Runs semantic search (if natural language query and mode allows)
- Runs keyword search (if keywords present and mode allows)
- Combines and re-ranks scores using RRF
- Applies metadata filters
- Returns top-k results
Sourcepub fn health_check(&self) -> Result<()>
pub fn health_check(&self) -> Result<()>
Health check for both engines
Sourcepub fn cached_metadata_count(&self) -> usize
pub fn cached_metadata_count(&self) -> usize
Get the number of events in the metadata cache
Sourcepub fn clear_metadata_cache(&self)
pub fn clear_metadata_cache(&self)
Clear the metadata cache
Auto Trait Implementations§
impl !Freeze for HybridSearchEngine
impl !RefUnwindSafe for HybridSearchEngine
impl Send for HybridSearchEngine
impl Sync for HybridSearchEngine
impl Unpin for HybridSearchEngine
impl !UnwindSafe for HybridSearchEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more