DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Mastering Persistence: Why the Persistence Layer Is Crucial for Modern Java Applications
  • From Database Changes to Real-Time Actions at Scale: Oracle GoldenGate and Java
  • Building High-Performance Time-Series Applications With Java and QuestDB
  • Building Time-Series Applications With Java and InfluxDB

Trending

  • Pitching Kotlin: An Engineering Leader's Guide to Legacy Modernization
  • Process Intelligence Landscape 2026: Mining, Orchestration, and the Agentic AI Shift
  • Simplifying the Hugging Face AI Agent Incident
  • Two AI Agents, One Database: Solving Concurrent Updates With Optimistic Locking

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Coding
  3. Java
  4. Getting Started With Milvus: Vector Search for Enterprise Java Applications

Getting Started With Milvus: Vector Search for Enterprise Java Applications

Integrate Milvus vector search into Java applications with Eclipse JNoSQL, LangChain4j, and familiar Jakarta persistence APIs.

By 
Otavio Santana
DZone Core CORE ·
Nov. 19, 26 · Analysis
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
83 Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

Artificial Intelligence is transforming enterprise information retrieval, but deploying semantic search in production involves more than generating embeddings. Applications must efficiently store, index, and retrieve millions of vectors while managing expanding datasets, concurrent requests, and operational demands. Milvus, a leading open-source vector database, addresses these needs. Built for high-performance similarity search, Milvus offers a specialized persistence engine that supports applications from recommendation systems to large-scale AI-powered search.

Java developers and software architects face the challenge of integrating these capabilities without adding complexity or tightly coupling business logic to a specific database. This article explores Milvus integration through Enterprise Java, showing how to connect enterprise Java applications to vector search using familiar persistence concepts. Before writing Java code, we will examine what sets Milvus apart, how its architecture works, and which configuration options matter when moving from local development to production.

Understanding Milvus: Architecture and Enterprise Capabilities

Milvus is an open-source vector database developed by Zilliz and contributed to the LF AI & Data Foundation. Unlike general-purpose databases that have added vector search over time, Milvus is purpose-built for high-performance similarity search. Its architecture is designed to efficiently manage millions or billions of vectors while ensuring consistent performance as workloads increase.

Milvus separates storage and computing resources, allowing ingestion, indexing, and querying components to scale independently. For example, an e-commerce platform facing higher search traffic can allocate more resources to query processing without increasing ingestion capacity.

Milvus offers several notable capabilities:

  • Flexible indexing: Supports algorithms such as HNSW, IVF, and DiskANN, enabling developers to balance search latency, recall, memory usage, and indexing costs.
  • Hardware acceleration: Provides CPU optimizations and GPU-based indexing for computationally intensive workloads.
  • Hybrid retrieval: Combines dense and sparse vector search, keyword retrieval, and metadata filtering to support advanced search scenarios.
  • Cloud-native scalability: Supports distributed deployments on Kubernetes with independent scaling and resource management.
  • Deployment flexibility: Provides Lite, Standalone, and Distributed options, although Milvus Lite is primarily designed for Python environments.

While these capabilities are not unique to Milvus, its key differentiator is the combination of specialized vector indexing, hardware optimization, and distributed architecture for large-scale workloads.

Milvus in Real-World Applications

Milvus is used beyond experimental AI applications. Its official documentation highlights organizations applying vector search to production use cases:

  • Walmart: Uses Milvus to support internal applications, including product search that matches customer queries with relevant product listings.
  • Roblox: Uses Milvus for internal applications, particularly avatar search, helping users discover relevant customization options.
  • European Patent Office: Applies vector search to patent retrieval, improving the discovery of technically related documents beyond exact terminology.

These examples show how vector databases support diverse business domains, including e-commerce, digital experiences, and intellectual property research. They also illustrate the relevance of vector search beyond conversational AI and RAG applications.

However, specialization introduces trade-offs. Milvus requires architects to consider indexing strategies, resource consumption, consistency requirements, and deployment complexity. A distributed cluster may suit billions of vectors, but it may be unnecessary for an application handling a relatively small dataset.

Developers do not need a distributed environment to start experimenting. Milvus offers a standalone deployment that runs locally with Docker, providing a practical starting point before integration with enterprise Java applications through Eclipse JNoSQL.

Setting Up Milvus With Eclipse JNoSQL

Milvus offers various deployment models, including standalone instances and distributed clusters. While distributed deployments are ideal for production workloads requiring scalability and high availability, this guide uses a single Docker container to simplify local development and highlight Java integration.

Once Docker is installed, start Milvus using the configuration from the example repository:

Shell
 
docker run -d --name milvus-standalone -p 19530:19530 -p 9091:9091 \
  -e DEPLOY_MODE=STANDALONE -e ETCD_USE_EMBED=true \
  -e ETCD_DATA_DIR=/var/lib/milvus/etcd -e COMMON_STORAGETYPE=local \
  milvusdb/milvus:v3.0.4 milvus run standalone


This configuration uses embedded etcd for metadata management and local storage, eliminating the need for additional containers. Milvus exposes port 19530 for client communication and port 9091 for management and health endpoints. This setup is intended for local experimentation, not production use.

Connecting Milvus With Eclipse JNoSQL

With Milvus running, integrate it into a Java application using Eclipse JNoSQL, which offers a unified persistence model for multiple NoSQL databases. Its CDI integration supports dependency injection

 in Jakarta EE environments, including REST applications, batch processing, and background services.

Although Eclipse JNoSQL supports Jakarta EE-compatible application servers, this example uses Java SE with CDI to keep the application lightweight and focused on vector persistence.

The Maven configuration includes the Milvus integration, Vector Mapping API, and LangChain4j for local embedding generation:

Java
 
<dependency>
    <groupId>org.eclipse.jnosql.databases</groupId>
    <artifactId>jnosql-milvus</artifactId>
    <version>${jnosql.version}</version>
</dependency>

<dependency>
    <groupId>org.eclipse.jnosql.mapping</groupId>
    <artifactId>jnosql-mapping-vector</artifactId>
    <version>${jnosql.version}</version>
</dependency>

<dependency>
    <groupId>dev.langchain4j</groupId>
    <artifactId>langchain4j-embeddings-all-minilm-l6-v2-q</artifactId>
    <version>${langchain4j.embeddings.version}</version>
</dependency>


This example uses Eclipse JNoSQL 1.2.0 via its parent Maven project and LangChain4j embedding dependency version 1.22.0-beta32.

Next, we configure the connection using MicroProfile Config in META-INF/microprofile-config.properties:

Properties files
 
jnosql.milvus.host=localhost
# Milvus gRPC endpoint
jnosql.milvus.port=19530
jnosql.milvus.timeout=60000
# all-MiniLM-L6-v2 produces 384-dimensional embeddings
jnosql.milvus.collection.vector.size=384


The configuration specifies the products collection and sets the vector dimension to 384 to match the local embedding model's output.

Unlike solutions that require an external AI provider, this example generates embeddings directly within the Java process using LangChain4j and an ONNX model. No external AI API, API key, or cloud account is needed.

With the database and Java dependencies configured, you can now explore how Eclipse JNoSQL maps product information, generates embeddings, and performs semantic searches using its VectorTemplate API.

Exploring the Eclipse JNoSQL API

With Milvus running and Java dependencies configured, we can focus on the persistence API. Eclipse JNoSQL extends Jakarta NoSQL, enabling developers to map Java objects to database records. In this example, we use a product catalog that supports semantic recommendations by combining product descriptions with vector representations.

The entity uses standard Jakarta NoSQL annotations and includes an additional attribute for the embedding:

Java
 
@Entity
public class Product {

    @Id
    private String id;

    @Column
    private String name;

    @Column
    private String description;

    @Column
    private ProductType type;

    @Column
    private Vector embedding;

    // Constructors and getters
}


Eclipse JNoSQL introduces VectorTemplate, a specialization of Jakarta NoSQL’s Template interface. Developers retain standard persistence operations such as insert(), find(), and delete(), and gain additional capabilities for similarity search.

In this example, LangChain4j generates the embedding locally. It must convert the numerical representation to Eclipse JNoSQL’s vector abstraction. This conversion is handled by a TextEmbedder component:

Java
 
@ApplicationScoped
public class TextEmbedder {

    private final EmbeddingModel model =
            new AllMiniLmL6V2QuantizedEmbeddingModel();

    public Vector embed(String text) {
        float[] values = model.embed(text)
                .content()
                .vector();

        return DenseVector.of(values);
    }
}


The DenseVector.of() method converts the embedding into a JNoSQL vector representation. This approach separates embedding generation from persistence, allowing applications to change their embedding provider independently of the database API.

We can now generate the vector and persist a product with VectorTemplate:

Java
 
String semanticText = """
        Product: %s
        Description: %s
        """.formatted(name, description);

Vector embedding = embedder.embed(semanticText);

Product product = new Product(
        id, name, description, type, embedding);

template.insert(product);


The embedding is generated from the product’s name and description, while the type remains metadata. This distinction allows the database to combine semantic similarity with structured conditions.

For example, if a customer searches for “something comfortable for my animal to rest,” the application generates an embedding for the request and searches for similar products instead of requiring an exact keyword match:

Java
 
Vector queryVector = embedder.embed(
    "something comfortable for my animal to rest"
);

List<Product> products = template.search(Product.class)
        .vector(queryVector)
        .limit(Limit.of(3))
        .result();


The fluent API also supports combining similarity search with structured filters. For example, results can be restricted to products classified as pet accessories:

Java
 
List<Product> products = template.search(Product.class)
        .vector(queryVector)
        .where("type").eq(ProductType.PET)
        .limit(Limit.of(3))
        .result();


This is especially useful for enterprise applications where semantic recommendations must respect business constraints such as product categories, availability, or access permissions.

Beyond Templates: Jakarta Data and Jakarta Query

Eclipse JNoSQL supports three complementary Jakarta specifications: Jakarta NoSQL, Jakarta Data, and Jakarta Query. Jakarta NoSQL provides entity mapping and template operations. Jakarta Data defines the repository abstraction. Jakarta Query offers a common foundation for persistence queries, with integration into Eclipse JNoSQL still under development.

For example, Jakarta Data allows developers to declare a repository without implementing the persistence operations manually:

Java
 
@Repository
public interface ProductRepository
        extends BasicRepository<Product, String> {
}


The repository provides standard operations such as save(), findById(), and deleteById(). It complements VectorTemplate, which handles specialized vector similarity searches. Repository methods do not automatically perform vector similarity operations.

This combination gives Java developers flexibility to choose the appropriate abstraction: repositories for common persistence operations and specialized templates for database-specific capabilities. Applications can retain a familiar Java programming model while using Milvus without exposing its native driver throughout the business layer.

The complete implementation, including Java SE bootstrap, embedding generation, product catalog, and search examples, is available in the Eclipse JNoSQL Milvus demo.

Conclusion

Milvus provides a scalable foundation for vector search, enabling enterprise applications to move beyond traditional data retrieval toward semantic recommendations and AI-powered experiences. With Eclipse JNoSQL, Java developers can integrate Milvus using familiar persistence patterns while keeping embedding generation separate from database operations. Although vector databases introduce new architectural considerations, understanding their capabilities and trade-offs helps developers make better technology decisions. To explore the implementation, check out the complete source code and discover more about polyglot persistence with Java at the Eclipse JNoSQL website.

Database applications Java (programming language)

Opinions expressed by DZone contributors are their own.

Related

  • Mastering Persistence: Why the Persistence Layer Is Crucial for Modern Java Applications
  • From Database Changes to Real-Time Actions at Scale: Oracle GoldenGate and Java
  • Building High-Performance Time-Series Applications With Java and QuestDB
  • Building Time-Series Applications With Java and InfluxDB

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook