pub struct LocalIndex { /* private fields */ }Expand description
Main LocalIndex implementation with full Node.js API compatibility
Implementations§
Source§impl LocalIndex
impl LocalIndex
Sourcepub fn with_storage(
folder_path: impl AsRef<Path>,
index_name: Option<String>,
storage: Box<dyn StorageBackend>,
) -> Result<Self>
pub fn with_storage( folder_path: impl AsRef<Path>, index_name: Option<String>, storage: Box<dyn StorageBackend>, ) -> Result<Self>
Creates a new LocalIndex instance with a provided storage backend
Sourcepub fn new<P: AsRef<Path>>(
folder_path: P,
index_name: Option<String>,
) -> Result<Self>
pub fn new<P: AsRef<Path>>( folder_path: P, index_name: Option<String>, ) -> Result<Self>
Creates a new LocalIndex instance (legacy API, requires storage dependency) This will be deprecated - use with_storage instead
Sourcepub async fn create_index(
&self,
config: Option<CreateIndexConfig>,
) -> Result<()>
pub async fn create_index( &self, config: Option<CreateIndexConfig>, ) -> Result<()>
Creates an index with optional configuration
Sourcepub async fn is_index_created(&self) -> bool
pub async fn is_index_created(&self) -> bool
Checks if index exists
Sourcepub async fn insert_item(
&self,
item: impl Into<VectorItem>,
) -> Result<VectorItem>
pub async fn insert_item( &self, item: impl Into<VectorItem>, ) -> Result<VectorItem>
Inserts a new item
Sourcepub async fn update_item(&self, update: UpdateRequest) -> Result<UpdateResult>
pub async fn update_item(&self, update: UpdateRequest) -> Result<UpdateResult>
Updates an existing item (partial update)
Sourcepub async fn upsert_item(
&self,
item: impl Into<VectorItem>,
) -> Result<VectorItem>
pub async fn upsert_item( &self, item: impl Into<VectorItem>, ) -> Result<VectorItem>
Upserts an item (insert or update)
Sourcepub async fn delete_item(&self, id: &Uuid) -> Result<()>
pub async fn delete_item(&self, id: &Uuid) -> Result<()>
Deletes an item
Sourcepub async fn list_items(
&self,
options: Option<ListOptions>,
) -> Result<Vec<VectorItem>>
pub async fn list_items( &self, options: Option<ListOptions>, ) -> Result<Vec<VectorItem>>
Lists all items with optional pagination
Sourcepub async fn query_items(
&self,
vector: Vec<f32>,
top_k: Option<u32>,
filter: Option<Value>,
) -> Result<Vec<QueryResult>>
pub async fn query_items( &self, vector: Vec<f32>, top_k: Option<u32>, filter: Option<Value>, ) -> Result<Vec<QueryResult>>
Query items - maintains Node.js signature compatibility
Sourcepub async fn query_items_extended(
&self,
vector: Vec<f32>,
text_query: Option<String>,
top_k: Option<u32>,
filter: Option<Value>,
) -> Result<Vec<QueryResult>>
pub async fn query_items_extended( &self, vector: Vec<f32>, text_query: Option<String>, top_k: Option<u32>, filter: Option<Value>, ) -> Result<Vec<QueryResult>>
Extended query with text search
Sourcepub async fn begin_update(&self) -> Result<()>
pub async fn begin_update(&self) -> Result<()>
Begins an update transaction
Sourcepub async fn end_update(&self) -> Result<()>
pub async fn end_update(&self) -> Result<()>
Ends an update transaction
Sourcepub async fn cancel_update(&self) -> Result<()>
pub async fn cancel_update(&self) -> Result<()>
Cancels an update transaction (now async for safety)
Sourcepub async fn delete_index(&self) -> Result<()>
pub async fn delete_index(&self) -> Result<()>
Deletes the entire index
Sourcepub async fn get_stats(&self) -> Result<IndexStats>
pub async fn get_stats(&self) -> Result<IndexStats>
Gets index statistics
Auto Trait Implementations§
impl Freeze for LocalIndex
impl !RefUnwindSafe for LocalIndex
impl Send for LocalIndex
impl Sync for LocalIndex
impl Unpin for LocalIndex
impl !UnwindSafe for LocalIndex
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