AppSearchVectorStore

public final class AppSearchVectorStore

A vector store implementation using Android system-level AppSearch storage.

Public Constructors

AppSearchVectorStore(Context context, String databaseName)

Public Methods

void
close()
void
delete(Map<String, String> metadataFilter)
Deletes the records matching the specified metadata filter.
void
delete(List<String> ids)
Deletes the records matching the specified IDs.
void
deleteAll()
Deletes all records from the vector store.
List<RetrievalRecord>
get(List<String> ids)
Retrieves the records matching the specified IDs (Key-Value lookup).
List<String>
getAllRecordIds()
Retrieves all unique record identifiers in the vector store.
List<RetrievalRecord>
search(float[] queryEmbedding, int topK)
Searches the top-K nearest records to the query embedding.
List<RetrievalRecord>
search(float[] queryEmbedding, int topK, Map<String, String> metadataFilter)
Searches the top-K nearest records matching the query embedding and metadata filter.
void
upsert(List<RetrievalRecord> records)
Upserts a list of records in the vector store.

Inherited Methods

Public Constructors

public AppSearchVectorStore (Context context, String databaseName)

Parameters
context
databaseName

Public Methods

public void close ()

Throws
Exception

public void delete (Map<String, String> metadataFilter)

Deletes the records matching the specified metadata filter.

Parameters
metadataFilter

public void delete (List<String> ids)

Deletes the records matching the specified IDs.

Parameters
ids

public void deleteAll ()

Deletes all records from the vector store.

public List<RetrievalRecord> get (List<String> ids)

Retrieves the records matching the specified IDs (Key-Value lookup).

Parameters
ids

public List<String> getAllRecordIds ()

Retrieves all unique record identifiers in the vector store.

public List<RetrievalRecord> search (float[] queryEmbedding, int topK)

Searches the top-K nearest records to the query embedding.

Parameters
queryEmbedding
topK

public List<RetrievalRecord> search (float[] queryEmbedding, int topK, Map<String, String> metadataFilter)

Searches the top-K nearest records matching the query embedding and metadata filter.

Parameters
queryEmbedding
topK
metadataFilter

public void upsert (List<RetrievalRecord> records)

Upserts a list of records in the vector store.

Parameters
records