org.llm4s.vectorstore.opensearch
Members list
Type members
Classlikes
How OpenSearchVectorStore authenticates to the cluster. Credentials are never printed by toString.
How OpenSearchVectorStore authenticates to the cluster. Credentials are never printed by toString.
The security plugin's HTTP basic authentication (its internal user database, as on a self-managed cluster or an Amazon OpenSearch Service domain with fine-grained access control) and bearer tokens (its JWT backend) are supported. AWS Signature Version 4 request signing (IAM) is not.
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
OpenSearchAuth.type
What OpenSearchVectorStore needs to reach one index of an OpenSearch cluster with the k-NN plugin.
What OpenSearchVectorStore needs to reach one index of an OpenSearch cluster with the k-NN plugin.
Load it from configuration with org.llm4s.config.OpenSearchVectorStoreConfigLoader, which reads llm4s.vectorstore.opensearch, or build one in code:
val config = OpenSearchConfig("https://search.example.com:9200")
.withIndex("docs")
.withAuth(OpenSearchAuth.Basic("llm4s", password))
.withEngine(OpenSearchEngine.Faiss)
The store checks it with OpenSearchConfig#validate when it is built.
Value parameters
- auth
-
the credentials, OpenSearchAuth.NoAuth by default
- baseUrl
-
the cluster's root URL, optionally with a path prefix (a proxy), without a query. It must be
httpswhen credentials are sent; plainhttpis accepted for a loopback host (localhost,127.0.0.0/8,::1) or when there are no credentials to protect. - dimensions
-
the vector size the index is created with; when unset, the size of the first record upserted. When set, a record of another size is refused before it is sent.
- efConstruction
-
the HNSW graph's
ef_construction; when unset, the engine's default - engine
-
the k-NN engine the index is created with; it decides whether filters are applied inside the kNN search (OpenSearchEngine#filtersInsideKnn)
- index
-
the index holding the vectors; OpenSearch's index-name rules apply (lower case, no
\ / * ? " < > | , #or space, not starting with-,_or+) - m
-
the HNSW graph's
m(links per node); when unset, the engine's default - numCandidates
-
the kNN query's
k, the neighbours each shard returns before the result is cut totopK. When unset:topKwith efficient filtering, andmax(100, 10 * topK)with a post-filter, so that enough candidates survive the filter. Never belowtopK, at most 10,000. - refreshOnWrite
-
whether writes wait for a refresh (
refresh=wait_for), so that a search straight after an upsert or delete sees it. Turn it off for bulk ingestion. - spaceType
-
the
knn_vectorspace the index is created with - timeout
-
how long each HTTP request may take
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Producttrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
OpenSearchConfig.type
The k-NN library behind a knn_vector field's HNSW graph, fixed when the index is created.
The k-NN library behind a knn_vector field's HNSW graph, fixed when the index is created.
Value parameters
- filtersInsideKnn
-
whether the engine supports efficient filtering - the metadata filter inside the
knnquery, applied while the graph is searched, sotopKresults come back when that many match. Without it the filter is applied to the kNN hits afterwards (a post-filter), which can return fewer thantopK. - wireName
-
the value of the mapping's
method.engineparameter
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
OpenSearchEngine.type
The k-NN space a knn_vector field is indexed with, fixed when the index is created.
The k-NN space a knn_vector field is indexed with, fixed when the index is created.
OpenSearch turns each space's distance into a non-negative _score of its own, the same on every OpenSearchEngine. OpenSearchVectorStore maps it onto [0, 1], so that a org.llm4s.vectorstore.ScoredRecord score reads like Elasticsearch's:
- OpenSearchSpaceType.CosineSimil: OpenSearch's own
(2 - (1 - cosine)) / 2 = (1 + cosine) / 2, kept. - OpenSearchSpaceType.InnerProduct:
(1 + dot) / 2, clamped, from OpenSearch'sdot + 1(fordot >= 0) or1 / (1 - dot)(fordot < 0). It lies in[0, 1]for unit vectors; other vectors are clamped. - OpenSearchSpaceType.L2: OpenSearch's own
1 / (1 + distance^2), already in(0, 1].
Value parameters
- wireName
-
the value of the mapping's
space_typeparameter
Attributes
- Companion
- object
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- enum
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
OpenSearchSpaceType.type
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.
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
- Supertypes
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type