pub struct TextIndex { /* private fields */ }Expand description
In-memory BM25 postings index for one node (label, property) pair.
Implementations§
Source§impl TextIndex
impl TextIndex
Sourcepub fn search_candidates(
&self,
query: &str,
candidates: &[NodeId],
k: usize,
) -> Vec<TextSearchHit>
pub fn search_candidates( &self, query: &str, candidates: &[NodeId], k: usize, ) -> Vec<TextSearchHit>
Rank explicit node candidates for query using this index’s BM25 corpus stats.
Candidate ids are deduplicated and missing/non-indexed ids are ignored.
Term document frequencies and average document length remain global to
the maintained index, so this returns the same ordering as a full
Self::search followed by candidate filtering when enough global hits
are materialized.
Sourcepub fn search_candidates_checked(
&self,
query: &str,
candidates: &[NodeId],
k: usize,
checker: CancellationChecker<'_>,
) -> Result<Vec<TextSearchHit>, TextSearchError>
pub fn search_candidates_checked( &self, query: &str, candidates: &[NodeId], k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<TextSearchHit>, TextSearchError>
Rank explicit node candidates for query with cooperative cancellation checks.
§Errors
Returns TextSearchError::Cancelled, TextSearchError::Timeout, or
TextSearchError::NodeScanBudgetExceeded when the supplied checker
trips while deduplicating or scoring candidates.
Source§impl TextIndex
impl TextIndex
Sourcepub fn build(
graph: &SeleneGraph,
label: DbString,
property: DbString,
) -> GraphResult<Self>
pub fn build( graph: &SeleneGraph, label: DbString, property: DbString, ) -> GraphResult<Self>
Build a postings index from the current graph snapshot.
Only alive nodes that carry label and whose property value is a
non-empty string document are indexed. Non-string values are ignored, which
matches the exact BM25 scan path.
§Errors
Returns GraphError::Inconsistent if the label index references a row
without a resolvable node id or property row.
Sourcepub fn empty(label: DbString, property: DbString) -> Self
pub fn empty(label: DbString, property: DbString) -> Self
Construct an empty postings index for label.property.
Sourcepub const fn rows(&self) -> &RoaringBitmap
pub const fn rows(&self) -> &RoaringBitmap
Return the indexed row bitmap.
Sourcepub fn document_count(&self) -> usize
pub fn document_count(&self) -> usize
Return the number of indexed string documents.
Sourcepub fn term_count(&self) -> usize
pub fn term_count(&self) -> usize
Return the number of distinct indexed terms.
Sourcepub const fn posting_count(&self) -> usize
pub const fn posting_count(&self) -> usize
Return the total number of term-document postings.
Sourcepub fn stats(&self) -> TextIndexStats
pub fn stats(&self) -> TextIndexStats
Return aggregate index counters.
Sourcepub fn memory_usage(&self) -> TextIndexMemoryUsage
pub fn memory_usage(&self) -> TextIndexMemoryUsage
Return an estimated memory usage snapshot for this index.
Sourcepub fn search(&self, query: &str, k: usize) -> Vec<TextSearchHit>
pub fn search(&self, query: &str, k: usize) -> Vec<TextSearchHit>
Rank indexed documents for query using BM25.
Sourcepub fn search_checked(
&self,
query: &str,
k: usize,
checker: CancellationChecker<'_>,
) -> Result<Vec<TextSearchHit>, TextSearchError>
pub fn search_checked( &self, query: &str, k: usize, checker: CancellationChecker<'_>, ) -> Result<Vec<TextSearchHit>, TextSearchError>
Rank indexed documents for query with cooperative cancellation checks.
The query path visits only postings for query terms, not every indexed document. Scores and tie ordering match the exact scan oracle.
§Errors
Returns TextSearchError::Cancelled, TextSearchError::Timeout, or
TextSearchError::NodeScanBudgetExceeded when the supplied checker
trips while collecting postings or scoring candidate documents.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TextIndex
impl RefUnwindSafe for TextIndex
impl Send for TextIndex
impl Sync for TextIndex
impl Unpin for TextIndex
impl UnsafeUnpin for TextIndex
impl UnwindSafe for TextIndex
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.