feat: refresh index if version changed (#14150)

This commit is contained in:
DarkSky
2025-12-26 01:08:05 +08:00
committed by GitHub
parent e8693a3a25
commit 2e38898937
19 changed files with 57 additions and 19 deletions

View File

@@ -74,7 +74,7 @@ impl SqliteDocStorage {
mod tests {
use sqlx::Row;
use super::*;
use super::{super::Data, *};
async fn get_storage() -> SqliteDocStorage {
let storage = SqliteDocStorage::new(":memory:".to_string());
@@ -91,7 +91,7 @@ mod tests {
storage
.set_blob(SetBlob {
key: format!("test_{}", i),
data: vec![0, 0],
data: Into::<Data>::into(vec![0, 0]),
mime: "text/plain".to_string(),
})
.await
@@ -131,7 +131,7 @@ mod tests {
storage
.set_blob(SetBlob {
key: format!("test_{}", i),
data: vec![0, 0],
data: Into::<Data>::into(vec![0, 0]),
mime: "text/plain".to_string(),
})
.await
@@ -179,7 +179,7 @@ mod tests {
storage
.set_blob(SetBlob {
key: format!("test_{}", i),
data: vec![0, 0],
data: Into::<Data>::into(vec![0, 0]),
mime: "text/plain".to_string(),
})
.await

View File

@@ -250,6 +250,7 @@ mod tests {
use chrono::{DateTime, Utc};
use super::*;
use crate::Data;
async fn get_storage() -> SqliteDocStorage {
let storage = SqliteDocStorage::new(":memory:".to_string());
@@ -293,7 +294,7 @@ mod tests {
storage
.set_doc_snapshot(DocRecord {
doc_id: "test".to_string(),
bin: vec![0, 0],
bin: Into::<Data>::into(vec![0, 0]),
timestamp: Utc::now().naive_utc(),
})
.await
@@ -373,7 +374,7 @@ mod tests {
let snapshot = DocRecord {
doc_id: "test".to_string(),
bin: vec![0, 0],
bin: Into::<Data>::into(vec![0, 0]),
timestamp: Utc::now().naive_utc(),
};
@@ -391,7 +392,7 @@ mod tests {
let snapshot = DocRecord {
doc_id: "test".to_string(),
bin: vec![0, 0],
bin: Into::<Data>::into(vec![0, 0]),
timestamp: Utc::now().naive_utc(),
};
@@ -404,7 +405,7 @@ mod tests {
let snapshot = DocRecord {
doc_id: "test".to_string(),
bin: vec![0, 1],
bin: Into::<Data>::into(vec![0, 1]),
timestamp: DateTime::from_timestamp_millis(Utc::now().timestamp_millis() - 1000)
.unwrap()
.naive_utc(),

View File

@@ -197,6 +197,10 @@ impl SqliteDocStorage {
Ok(())
}
pub fn index_version() -> u32 {
memory_indexer::InMemoryIndex::snapshot_version()
}
pub async fn fts_add(
&self,
index_name: &str,

View File

@@ -472,6 +472,11 @@ impl DocStoragePool {
Ok(())
}
#[napi]
pub async fn fts_index_version(&self) -> Result<u32> {
Ok(SqliteDocStorage::index_version())
}
#[napi]
pub async fn fts_delete_document(
&self,