pub struct FtsCollectionManager { /* private fields */ }Expand description
Manages per-collection (and per-field) in-memory full-text search indexes.
Each (collection, field) pair gets its own FtsIndex<MemoryBackend>.
The bare "{collection}" key holds whole-document text (all string
fields concatenated), searched when a caller names no field.
Implementations§
Source§impl FtsCollectionManager
impl FtsCollectionManager
Sourcepub fn set_collection_analyzer(
&mut self,
collection: &str,
analyzer_name: &str,
) -> Result<(), LiteError>
pub fn set_collection_analyzer( &mut self, collection: &str, analyzer_name: &str, ) -> Result<(), LiteError>
Bind analyzer_name to every index belonging to collection, and
retain it so indexes created later inherit the same analyzer.
Unrecognized names fall back to the standard analyzer inside nodedb-fts at resolve time, matching Origin’s behavior. Fails when an index cannot record the binding.
Source§impl FtsCollectionManager
impl FtsCollectionManager
Sourcepub fn index_document_fields(
&mut self,
collection: &str,
doc_id: &str,
fields: &HashMap<String, Value>,
) -> Result<Vec<(String, String)>, LiteError>
pub fn index_document_fields( &mut self, collection: &str, doc_id: &str, fields: &HashMap<String, Value>, ) -> Result<Vec<(String, String)>, LiteError>
Index a schemaless document: its whole-document text under the bare
"{collection}" key and each top-level string field under
"{collection}:{field}".
Replaces whatever the document held before. The document is retracted from every other field index of the collection, so a field it no longer carries as a string stops matching. A field with an empty name has no key of its own and is searchable through the whole-document index only.
Returns the indexed (field, text) pairs sorted by field name, without
empty field names. The list is empty when the document holds no
indexable string field.
Sourcepub fn remove_document_fields(
&self,
collection: &str,
doc_id: &str,
) -> Result<(), LiteError>
pub fn remove_document_fields( &self, collection: &str, doc_id: &str, ) -> Result<(), LiteError>
Remove a document from every index of collection: the
whole-document index and each per-field index.
Sourcepub fn index_document(
&mut self,
collection: &str,
doc_id: &str,
text: &str,
) -> Result<(), LiteError>
pub fn index_document( &mut self, collection: &str, doc_id: &str, text: &str, ) -> Result<(), LiteError>
Index text as a document’s whole-document entry.
The document is stored under the bare "{collection}" key.
Calling again with the same doc_id replaces the previous entry.
Empty text is a removal, not a no-op: a document updated until it has no indexable words must stop matching the words it used to contain.
Sourcepub fn remove_document(
&self,
collection: &str,
doc_id: &str,
) -> Result<(), LiteError>
pub fn remove_document( &self, collection: &str, doc_id: &str, ) -> Result<(), LiteError>
Remove a document from the whole-document index.
Sourcepub fn index_field(
&mut self,
collection: &str,
field: &str,
doc_id: &str,
text: &str,
) -> Result<(), LiteError>
pub fn index_field( &mut self, collection: &str, field: &str, doc_id: &str, text: &str, ) -> Result<(), LiteError>
Index a single field value for a document.
Key is "{collection}:{field}". Calling again with the same doc_id
replaces the previous entry (upsert semantics).
Empty text is a removal, not a no-op: clearing a field must stop the document matching the words that field used to contain.
Sourcepub fn remove_field(
&self,
collection: &str,
field: &str,
doc_id: &str,
) -> Result<(), LiteError>
pub fn remove_field( &self, collection: &str, field: &str, doc_id: &str, ) -> Result<(), LiteError>
Remove a document’s entry from the field index of a collection.
Sourcepub fn register_origin_surrogate(
&mut self,
origin_surrogate: Surrogate,
doc_id: &str,
)
pub fn register_origin_surrogate( &mut self, origin_surrogate: Surrogate, doc_id: &str, )
Register an association between an Origin global surrogate and the
Lite string doc_id. Called from the FtsIndexDoc execution arm so
FtsDeleteDoc can later resolve the Origin surrogate to a string doc_id
and call the proper single-doc removal instead of dropping the collection.
Sourcepub fn remove_by_origin_surrogate(
&mut self,
collection: &str,
origin_surrogate: Surrogate,
) -> Result<Option<String>, LiteError>
pub fn remove_by_origin_surrogate( &mut self, collection: &str, origin_surrogate: Surrogate, ) -> Result<Option<String>, LiteError>
Remove a single document identified by its Origin-assigned surrogate.
Returns the removed doc_id, or None if the surrogate has no known
Lite mapping (e.g. it was never indexed via this Lite instance).
Source§impl FtsCollectionManager
impl FtsCollectionManager
Sourcepub fn phrase_search(
&self,
collection: &str,
field: &str,
terms: &[String],
top_k: usize,
params: &TextSearchParams,
) -> Result<Vec<FtsResult>, LiteError>
pub fn phrase_search( &self, collection: &str, field: &str, terms: &[String], top_k: usize, params: &TextSearchParams, ) -> Result<Vec<FtsResult>, LiteError>
Search the field index for documents where terms appear as an
exact consecutive phrase. An empty field searches the
whole-document index.
The phrase runs through the index’s analyzer first, so it matches the same stemmed, lower-cased tokens the documents were indexed as. Candidates are the documents holding every token at consecutive positions. Each one scores its BM25 score for the phrase with an earlier-position bonus.
Source§impl FtsCollectionManager
impl FtsCollectionManager
pub fn new(governor: Arc<MemoryGovernor>) -> Self
Sourcepub fn collection_count(&self) -> usize
pub fn collection_count(&self) -> usize
Number of distinct collection prefixes with active indexes.
Sourcepub fn has_text_index(&self, collection: &str) -> bool
pub fn has_text_index(&self, collection: &str) -> bool
Whether any document of collection was ever text-indexed.
Sourcepub fn drop_collection(&mut self, collection: &str)
pub fn drop_collection(&mut self, collection: &str)
Drop all FTS indexes for a collection (called on collection drop/truncate).
Source§impl FtsCollectionManager
impl FtsCollectionManager
Sourcepub fn search(
&self,
collection: &str,
field: &str,
query: &str,
top_k: usize,
params: &TextSearchParams,
) -> Result<Vec<FtsResult>, LiteError>
pub fn search( &self, collection: &str, field: &str, query: &str, top_k: usize, params: &TextSearchParams, ) -> Result<Vec<FtsResult>, LiteError>
Search the collection’s field index. An empty field searches the whole-document index.
Collections without indexed text return an empty list.
TextSearchParams controls boolean mode and fuzzy matching.
Queries without matching documents return an empty list. Read errors propagate.
Sourcepub fn scan_all_with_scores(
&self,
collection: &str,
field: &str,
query: &str,
params: &TextSearchParams,
allowed: Option<&HashSet<String>>,
) -> Result<Vec<(String, f32)>, LiteError>
pub fn scan_all_with_scores( &self, collection: &str, field: &str, query: &str, params: &TextSearchParams, allowed: Option<&HashSet<String>>, ) -> Result<Vec<(String, f32)>, LiteError>
Return every document the field index of collection holds, with
its BM25 score against query. Documents outside the BM25 hit set
score 0.0. This powers the score columns of text reads.
allowed restricts the documents to the named ones. The query’s
AND-mode fallback is then decided over those documents only.
Auto Trait Implementations§
impl !RefUnwindSafe for FtsCollectionManager
impl !Sync for FtsCollectionManager
impl Freeze for FtsCollectionManager
impl Send for FtsCollectionManager
impl Unpin for FtsCollectionManager
impl UnsafeUnpin for FtsCollectionManager
impl UnwindSafe for FtsCollectionManager
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
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.Source§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.