pub struct TextEngine { /* private fields */ }Expand description
BM25 全文搜索引擎
内部委托 SearchStore(SQLite FTS5)完成索引和搜索。 公开 API 保持不变,供 pipeline 和 CLI 调用。
Implementations§
Source§impl TextEngine
impl TextEngine
Sourcepub fn open(path: impl AsRef<Path>) -> Result<(Self, bool)>
pub fn open(path: impl AsRef<Path>) -> Result<(Self, bool)>
打开或创建持久化搜索引擎。
path 指向 SQLite 数据库文件(.db),不存在时自动创建。 返回 (engine, need_reindex):need_reindex=true 表示旧 schema 已 迁移重建(索引为空),调用方必须全量重索引(增量路径只补 changed_files 会丢失旧实体)。
Sourcepub fn search(&self, query: &str, limit: usize) -> Result<Vec<(CodeNode, f64)>>
pub fn search(&self, query: &str, limit: usize) -> Result<Vec<(CodeNode, f64)>>
BM25 搜索,返回 (CodeNode, score) 按相关性降序。
Sourcepub fn remove_by_file(&mut self, file_path: &str) -> Result<usize>
pub fn remove_by_file(&mut self, file_path: &str) -> Result<usize>
删除指定文件路径关联的所有索引条目。
Auto Trait Implementations§
impl !Freeze for TextEngine
impl !RefUnwindSafe for TextEngine
impl !Sync for TextEngine
impl !UnwindSafe for TextEngine
impl Send for TextEngine
impl Unpin for TextEngine
impl UnsafeUnpin for TextEngine
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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