Skip to main content

LocalIndex

Struct LocalIndex 

Source
pub struct LocalIndex { /* private fields */ }
Expand description

Main LocalIndex implementation with full Node.js API compatibility

Implementations§

Source§

impl LocalIndex

Source

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

Source

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

Source

pub async fn create_index( &self, config: Option<CreateIndexConfig>, ) -> Result<()>

Creates an index with optional configuration

Source

pub async fn is_index_created(&self) -> bool

Checks if index exists

Source

pub async fn insert_item( &self, item: impl Into<VectorItem>, ) -> Result<VectorItem>

Inserts a new item

Source

pub async fn update_item(&self, update: UpdateRequest) -> Result<UpdateResult>

Updates an existing item (partial update)

Source

pub async fn upsert_item( &self, item: impl Into<VectorItem>, ) -> Result<VectorItem>

Upserts an item (insert or update)

Source

pub async fn get_item(&self, id: &Uuid) -> Result<Option<VectorItem>>

Gets an item by ID

Source

pub async fn delete_item(&self, id: &Uuid) -> Result<()>

Deletes an item

Source

pub async fn list_items( &self, options: Option<ListOptions>, ) -> Result<Vec<VectorItem>>

Lists all items with optional pagination

Source

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

Source

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

Source

pub async fn begin_update(&self) -> Result<()>

Begins an update transaction

Source

pub async fn end_update(&self) -> Result<()>

Ends an update transaction

Source

pub async fn cancel_update(&self) -> Result<()>

Cancels an update transaction (now async for safety)

Source

pub async fn delete_index(&self) -> Result<()>

Deletes the entire index

Source

pub async fn get_stats(&self) -> Result<IndexStats>

Gets index statistics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.