A org.llm4s.vectorstore.VectorStore over one OpenSearch index with the k-NN plugin, through its REST API and org.llm4s.http.Llm4sHttpClient: no OpenSearch client library is involved.
It shares everything but the vector field and the kNN query with org.llm4s.vectorstore.elasticsearch.ElasticsearchVectorStore - OpenSearch keeps Elasticsearch 7.10's document, _bulk, _mget, _count, _delete_by_query and query DSL APIs - so records, writes, get, list, count, deletes, stats and every org.llm4s.vectorstore.MetadataFilter behave exactly as they do there.
What differs:
- the index is created on the first upsert with
index.knn: trueand aknn_vectorfield sized to OpenSearchConfig#dimensions (or the first record), indexed as an HNSW graph with the configured OpenSearchSpaceType and OpenSearchEngine; searchis aknnquery. On Lucene and Faiss the metadata filter goes inside it (efficient filtering), sotopKresults come back when that many match; on NMSLIB, which has no efficient filtering, the filter is applied to theknearest neighbours afterwards, so a selective filter can return fewer thantopK- raise OpenSearchConfig#numCandidates to compensate;- each
_scoreis mapped onto[0, 1]per space type, as OpenSearchSpaceType describes; - authentication is basic or a bearer token (OpenSearchAuth); AWS SigV4 signing is not supported.
Every operation returns a Result: a transport failure is the client's org.llm4s.error.NetworkError or org.llm4s.error.TimeoutError, a 401 or 403 an org.llm4s.error.AuthenticationError, a 429 a org.llm4s.error.RateLimitError, any other non-2xx status a org.llm4s.error.ServiceError carrying the status and the (redacted) body.
Attributes
- Companion
- object
- Graph
-
- Supertypes
Members list
Value members
Concrete methods
Clear all records from the store.
Clear all records from the store.
Attributes
- Returns
-
Success or error
- Definition Classes
Closes the HTTP client when this store created it; a client passed in belongs to the caller.
Closes the HTTP client when this store created it; a client passed in belongs to the caller.
Attributes
- Definition Classes
Count total records in the store.
Count total records in the store.
Value parameters
- filter
-
Optional metadata filter
Attributes
- Returns
-
Record count
- Definition Classes
Delete a record by its ID.
Delete a record by its ID.
Value parameters
- id
-
The record identifier
Attributes
- Returns
-
Success or error
- Definition Classes
Delete multiple records by their IDs.
Delete multiple records by their IDs.
Value parameters
- ids
-
The record identifiers
Attributes
- Returns
-
Success or error
- Definition Classes
Delete all records matching a metadata filter.
Delete all records matching a metadata filter.
Value parameters
- filter
-
The metadata filter
Attributes
- Returns
-
Number of records deleted
- Definition Classes
Delete all records with IDs starting with the given prefix.
Delete all records with IDs starting with the given prefix.
Value parameters
- prefix
-
The ID prefix to match
Attributes
- Returns
-
Number of records deleted
- Definition Classes
Retrieve a record by its ID.
Retrieve a record by its ID.
Value parameters
- id
-
The record identifier
Attributes
- Returns
-
The record if found
- Definition Classes
Retrieve multiple records by their IDs.
Retrieve multiple records by their IDs.
Value parameters
- ids
-
The record identifiers
Attributes
- Returns
-
The found records (missing IDs are silently skipped)
- Definition Classes
List records with pagination.
List records with pagination.
Value parameters
- filter
-
Optional metadata filter
- limit
-
Maximum records to return
- offset
-
Number of records to skip
Attributes
- Returns
-
Records in insertion order
- Definition Classes
Search for similar vectors using cosine similarity.
Search for similar vectors using cosine similarity.
Value parameters
- filter
-
Optional metadata filter
- queryVector
-
The query embedding
- topK
-
Number of results to return
Attributes
- Returns
-
Matching records with similarity scores
- Definition Classes
Get statistics about the vector store.
Get statistics about the vector store.
Attributes
- Returns
-
Store statistics
- Definition Classes
Store a vector record.
Store a vector record.
If a record with the same ID exists, it will be replaced.
Value parameters
- record
-
The record to store
Attributes
- Returns
-
Success or error
- Definition Classes
Store multiple vector records in a batch.
Store multiple vector records in a batch.
More efficient than individual upserts for bulk operations.
Value parameters
- records
-
The records to store
Attributes
- Returns
-
Success or error
- Definition Classes