Class OpenSearchEmbeddingStore
java.lang.Object
dev.langchain4j.store.embedding.opensearch.OpenSearchEmbeddingStore
- All Implemented Interfaces:
EmbeddingStore<TextSegment>
Represents an OpenSearch index as an
embedding store. This implementation uses K-NN and the cosinesimil space type.
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchEmbeddingStore(String serverUrl, String apiKey, String userName, String password, String indexName) Creates an instance of OpenSearchEmbeddingStore to connect with OpenSearch clusters running locally and network reachable.OpenSearchEmbeddingStore(String serverUrl, String serviceName, String region, org.opensearch.client.transport.aws.AwsSdk2TransportOptions options, String indexName) Creates an instance of OpenSearchEmbeddingStore to connect with OpenSearch clusters running as a fully managed service at AWS.OpenSearchEmbeddingStore(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName) Creates an instance of OpenSearchEmbeddingStore using provided OpenSearchClient -
Method Summary
Modifier and TypeMethodDescriptionadd(Embedding embedding, TextSegment textSegment) voidaddAll(List<Embedding> embeddings, List<TextSegment> embedded) builder()findRelevant(Embedding referenceEmbedding, int maxResults, double minScore) This implementation uses the exact k-NN with scoring script to calculate See https://opensearch.org/docs/latest/search-plugins/knn/knn-score-script/Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.langchain4j.store.embedding.EmbeddingStore
findRelevant, findRelevant, findRelevant
-
Constructor Details
-
OpenSearchEmbeddingStore
public OpenSearchEmbeddingStore(String serverUrl, String apiKey, String userName, String password, String indexName) Creates an instance of OpenSearchEmbeddingStore to connect with OpenSearch clusters running locally and network reachable.- Parameters:
serverUrl- OpenSearch Server URL.apiKey- OpenSearch API key (optional)userName- OpenSearch username (optional)password- OpenSearch password (optional)indexName- OpenSearch index name.
-
OpenSearchEmbeddingStore
public OpenSearchEmbeddingStore(String serverUrl, String serviceName, String region, org.opensearch.client.transport.aws.AwsSdk2TransportOptions options, String indexName) Creates an instance of OpenSearchEmbeddingStore to connect with OpenSearch clusters running as a fully managed service at AWS.- Parameters:
serverUrl- OpenSearch Server URL.serviceName- The AWS signing service name, one of `es` (Amazon OpenSearch) or `aoss` (Amazon OpenSearch Serverless).region- The AWS region for which requests will be signed. This should typically match the region in `serverUrl`.options- The options to establish connection with the service. It must include which credentials should be used.indexName- OpenSearch index name.
-
OpenSearchEmbeddingStore
public OpenSearchEmbeddingStore(org.opensearch.client.opensearch.OpenSearchClient openSearchClient, String indexName) Creates an instance of OpenSearchEmbeddingStore using provided OpenSearchClient- Parameters:
openSearchClient- OpenSearch client providedindexName- OpenSearch index name.
-
-
Method Details
-
builder
-
add
- Specified by:
addin interfaceEmbeddingStore<TextSegment>
-
add
- Specified by:
addin interfaceEmbeddingStore<TextSegment>
-
add
- Specified by:
addin interfaceEmbeddingStore<TextSegment>
-
addAll
- Specified by:
addAllin interfaceEmbeddingStore<TextSegment>
-
addAll
- Specified by:
addAllin interfaceEmbeddingStore<TextSegment>
-
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding referenceEmbedding, int maxResults, double minScore) This implementation uses the exact k-NN with scoring script to calculate See https://opensearch.org/docs/latest/search-plugins/knn/knn-score-script/- Specified by:
findRelevantin interfaceEmbeddingStore<TextSegment>
-