Class ElasticsearchContentRetriever
java.lang.Object
dev.langchain4j.store.embedding.elasticsearch.AbstractElasticsearchEmbeddingStore
dev.langchain4j.rag.content.retriever.elasticsearch.ElasticsearchContentRetriever
- All Implemented Interfaces:
ContentRetriever, EmbeddingStore<TextSegment>
public class ElasticsearchContentRetriever
extends AbstractElasticsearchEmbeddingStore
implements ContentRetriever
Represents an Elasticsearch index as a
ContentRetriever.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class AbstractElasticsearchEmbeddingStore
client, configuration, indexName -
Constructor Summary
ConstructorsConstructorDescriptionElasticsearchContentRetriever(ElasticsearchConfiguration configuration, org.elasticsearch.client.RestClient restClient, String indexName, EmbeddingModel embeddingModel, int maxResults, double minScore, Filter filter) Creates an instance of ElasticsearchContentRetriever using a RestClient. -
Method Summary
Methods inherited from class AbstractElasticsearchEmbeddingStore
add, add, add, add, add, addAll, addAll, addAllText, fullTextSearch, hybridSearch, initialize, removeAll, removeAll, removeAll, searchMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContentRetriever
addListener, addListenersMethods inherited from interface EmbeddingStore
addAll, addListener, addListeners, generateIds, remove
-
Constructor Details
-
ElasticsearchContentRetriever
public ElasticsearchContentRetriever(ElasticsearchConfiguration configuration, org.elasticsearch.client.RestClient restClient, String indexName, EmbeddingModel embeddingModel, int maxResults, double minScore, Filter filter) Creates an instance of ElasticsearchContentRetriever using a RestClient.- Parameters:
configuration- Elasticsearch retriever configuration to use (knn, script, full text, hybrid, hybrid with reranker)restClient- Elasticsearch Rest Client (mandatory)indexName- Elasticsearch index name (optional). Default value: "default". Index will be created automatically if not exists.embeddingModel- Embedding model to be used by the retrievermaxResults- Maximum number of results to retrieveminScore- Minimum score threshold for retrieved resultsfilter- Filter to apply during retrieval
-
-
Method Details
-
retrieve
Description copied from interface:ContentRetrieverRetrieves relevantContents using a givenQuery. TheContents are sorted by relevance, with the most relevantContents appearing at the beginning of the returnedList<Content>.- Specified by:
retrievein interfaceContentRetriever- Parameters:
query- TheQueryto use for retrieval.- Returns:
- A list of retrieved
Contents.
-
builder
-