Class MilvusEngine

java.lang.Object
dyntabs.ai.rag.MilvusEngine

public final class MilvusEngine extends Object
Bridges EasyAI to a persistent Milvus vector store, the way RagEngine bridges to an ephemeral in-memory store.

Analogy: RagEngine is like an in-memory HashMap that you rebuild every time the app starts; MilvusEngine is like a real database table — you write rows once, and they're still there next week for anyone to read. The ingest(java.util.List<dev.langchain4j.data.document.Document>, dyntabs.ai.rag.MilvusConfig) method is the INSERT, createRetriever(dyntabs.ai.rag.MilvusConfig, int, double) is the SELECT ... ORDER BY similarity, and createStore(dyntabs.ai.rag.MilvusConfig) is the Connection both share.

Unlike RagEngine, which rebuilds an InMemoryEmbeddingStore on every assistant build, a Milvus collection lives outside the JVM: you ingest documents once (write path) and any number of assistants can retrieve from it later (read path).

Both paths use the default embedding model provided on the classpath by the langchain4j-easy-rag module (via ServiceLoader), so ingestion and retrieval embed with the same model and dimensions line up automatically.

See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    static dev.langchain4j.rag.content.retriever.ContentRetriever
    createRetriever(MilvusConfig config, int maxResults, double minScore)
    Builds a ContentRetriever that reads from an existing Milvus collection, for wiring into an AI assistant.
    static dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment>
    Opens (creating if necessary) the Milvus collection described by config and returns it as a LangChain4J EmbeddingStore.
    static int
    ingest(List<dev.langchain4j.data.document.Document> documents, MilvusConfig config)
    Ingests already-loaded documents into the Milvus collection: splits each document, embeds the segments, and persists them.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • createStore

      public static dev.langchain4j.store.embedding.EmbeddingStore<dev.langchain4j.data.segment.TextSegment> createStore(MilvusConfig config)
      Opens (creating if necessary) the Milvus collection described by config and returns it as a LangChain4J EmbeddingStore.
      Parameters:
      config - the Milvus connection settings
      Returns:
      a ready-to-use embedding store backed by Milvus
    • ingest

      public static int ingest(List<dev.langchain4j.data.document.Document> documents, MilvusConfig config)
      Ingests already-loaded documents into the Milvus collection: splits each document, embeds the segments, and persists them. Metadata travels with each segment as a single JSON field (the LangChain4J model) and is available for filtering at query time.
      Parameters:
      documents - the documents to persist (already parsed/loaded)
      config - the target Milvus collection
      Returns:
      the number of documents ingested
    • createRetriever

      public static dev.langchain4j.rag.content.retriever.ContentRetriever createRetriever(MilvusConfig config, int maxResults, double minScore)
      Builds a ContentRetriever that reads from an existing Milvus collection, for wiring into an AI assistant.
      Parameters:
      config - the Milvus collection to retrieve from
      maxResults - maximum relevant segments to retrieve per query
      minScore - minimum relevance score (0.0 to 1.0)
      Returns:
      a configured ContentRetriever backed by Milvus