pub struct SearchStore { /* private fields */ }Expand description
SQLite 搜索引擎存储
管理一个 SQLite 数据库文件,包含:
entitiesFTS5 虚拟表(全文搜索)
Implementations§
Source§impl SearchStore
impl SearchStore
Sourcepub fn open(path: impl AsRef<Path>) -> Result<(Self, bool)>
pub fn open(path: impl AsRef<Path>) -> Result<(Self, bool)>
打开或创建数据库,初始化表结构。
设置 WAL 模式和 busy_timeout 以支持并发读取。 返回 (store, need_reindex):need_reindex=true 表示旧 schema 已 迁移重建(表为空),调用方必须全量重索引文本(增量路径不能只 补 changed_files,否则旧实体索引丢失)。
Sourcepub fn search_fts(
&self,
query: &str,
limit: usize,
) -> Result<Vec<(CodeNode, f64)>>
pub fn search_fts( &self, query: &str, limit: usize, ) -> Result<Vec<(CodeNode, f64)>>
FTS5 全文搜索,按 BM25 相关性排序
Sourcepub fn delete_entities_by_file(&self, file_path: &str) -> Result<usize>
pub fn delete_entities_by_file(&self, file_path: &str) -> Result<usize>
删除指定文件的所有 FTS5 条目
参数与 file_path 列同基准:写入时已归一化(票 08),删除键也归一化, 保证 Windows 反斜杠路径(调用方传入)与入库正斜杠键精确匹配。
Sourcepub fn entity_count(&self) -> Result<usize>
pub fn entity_count(&self) -> Result<usize>
获取 FTS5 表中的文档总数
Sourcepub fn clear_entities(&self) -> Result<()>
pub fn clear_entities(&self) -> Result<()>
清空 FTS5 表
Auto Trait Implementations§
impl !Freeze for SearchStore
impl !RefUnwindSafe for SearchStore
impl !Sync for SearchStore
impl !UnwindSafe for SearchStore
impl Send for SearchStore
impl Unpin for SearchStore
impl UnsafeUnpin for SearchStore
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