Class InfinispanContentRetriever

java.lang.Object
dev.langchain4j.rag.content.retriever.infinispan.InfinispanContentRetriever
All Implemented Interfaces:
ContentRetriever

public class InfinispanContentRetriever extends Object implements ContentRetriever
An Infinispan-backed ContentRetriever that uses full-text search (Ickle queries) to retrieve relevant content. The query does not need an embedding model.

Built from an existing InfinispanEmbeddingStore, reusing its remote cache and configuration. The store's schema must have full-text indexing enabled on the text field (use InfinispanStoreConfiguration.TEXT_FIELD_ANNOTATION_FULLTEXT when building the store).

  • Constructor Details

    • InfinispanContentRetriever

      public InfinispanContentRetriever(InfinispanEmbeddingStore embeddingStore, int maxResults)
  • Method Details

    • retrieve

      public List<Content> retrieve(Query query)
      Description copied from interface: ContentRetriever
      Retrieves relevant Contents using a given Query. The Contents are sorted by relevance, with the most relevant Contents appearing at the beginning of the returned List<Content>.
      Specified by:
      retrieve in interface ContentRetriever
      Parameters:
      query - The Query to use for retrieval.
      Returns:
      A list of retrieved Contents.
    • retrieveAsync

      public CompletableFuture<List<Content>> retrieveAsync(Query query)
      Description copied from interface: ContentRetriever
      Non-blocking counterpart of ContentRetriever.retrieve(Query), invoked by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service modes when RAG is configured.

      The default implementation returns a failed future carrying AsyncNotSupportedException: a retriever backed by blocking I/O (embedding-model call, vector-store query, web search, etc.) must opt in by overriding this method so it can return a genuinely non-blocking future instead of secretly tying up a worker thread. A retriever that cannot be made non-blocking is still usable from these modes via DefaultRetrievalAugmentor, which offloads the blocking ContentRetriever.retrieve(Query) to its executor.

      An implementation that honors cancellation should abort its in-flight I/O when the returned future is cancelled (best-effort); Java cannot safely interrupt arbitrary code, so this is not guaranteed.

      An implementation must not throw and must not return null: every failure, including an invalid argument, completes the returned future exceptionally.

      Specified by:
      retrieveAsync in interface ContentRetriever
      Parameters:
      query - The Query to use for retrieval.
      Returns:
      A CompletableFuture of the retrieved Contents, sorted by relevance.
    • builder

      public static InfinispanContentRetriever.Builder builder()