Interface VectorIndex


public interface VectorIndex
Storage backend for VectorMemoryStore.

The in-memory implementation is the default. Optional adapters (Qdrant, pgvector) implement this seam so tnsai-core stays free of vector-database clients.

Since:
0.14.0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Drops every stored entry.
    boolean
    Removes one entry.
    searchByVector(float[] queryVector, int topK)
    Returns the top-topK entries by cosine similarity.
    int
    Number of stored entries.
    void
    upsert(String id, MemoryEntry entry, float[] vector)
    Inserts or replaces one entry and its embedding.
  • Method Details

    • upsert

      void upsert(String id, MemoryEntry entry, float[] vector)
      Inserts or replaces one entry and its embedding.
      Parameters:
      id - entry identifier
      entry - memory entry
      vector - embedding snapshot owned by the caller
    • remove

      boolean remove(String id)
      Removes one entry.
      Parameters:
      id - entry identifier
      Returns:
      true when the entry was present
    • clear

      void clear()
      Drops every stored entry.
    • size

      int size()
      Number of stored entries.
    • searchByVector

      List<ScoredEntry> searchByVector(float[] queryVector, int topK)
      Returns the top-topK entries by cosine similarity.
      Parameters:
      queryVector - query embedding
      topK - maximum results
      Returns:
      scored entries, highest first