Getting Started With Weaviate: Building AI-Powered Search Applications With Java
Explore Weaviate vector search with enterprise Java using Eclipse JNoSQL, Docker, and LangChain4j for semantic retrieval and vector persistence.
Developing AI-powered enterprise applications involves challenges beyond vector storage and retrieval. Developers need to integrate embedding models, support semantic and keyword searches, and manage infrastructure that connects databases to AI services. As requirements expand, maintaining separate components becomes more complex. Weaviate, an open-source vector database built for AI integration, addresses these issues by unifying vector search, hybrid retrieval, and optional machine learning integrations in a single platform.
Weaviate enables Java developers and software architects to simplify intelligent search architectures while maintaining control over data persistence and AI integration. Its modular design supports various embedding providers, retrieval strategies, and deployment environments. This article examines Weaviate's capabilities, demonstrates local configuration with Docker, and shows integration with enterprise Java using Eclipse JNoSQL. Before implementation, we will review what sets Weaviate apart and its practical benefits.
Understanding Weaviate: Architecture and Real-World Applications
Weaviate is an open-source vector database written in Go that manages structured objects and their vector representations. Its modular AI integration architecture distinguishes it from other solutions. Developers can connect embedding models, rerankers, and generative AI services directly to the database, minimizing the need for independent orchestration at the application layer.
For example, in an enterprise knowledge management platform with technical documentation, internal procedures, and support articles, a developer searching for “how to improve Java application performance” benefits from semantic retrieval. In contrast, a search with an exact error code requires precise keyword matching. Weaviate addresses both needs through hybrid search, combining vector similarity with BM25 keyword retrieval and configurable ranking strategies.
Weaviate offers several features relevant to enterprise architectures:
- Integrated AI models: Optional modules connect to embedding providers, rerankers, and generative AI models. Applications may also generate embeddings externally and provide their own vectors.
- Hybrid search: Combines semantic similarity and keyword matching, allowing developers to balance conceptual relevance with exact terminology.
- Named vectors: Associates multiple vector representations with an object, enabling different embedding strategies for the same information.
- Multi-tenancy: Supports tenant-specific data isolation within collections, making it useful for SaaS applications serving multiple organizations.
- Flexible indexing: Offers HNSW, flat, and dynamic vector indexes, giving architects options for balancing resource consumption and retrieval performance.
While these capabilities are not unique to Weaviate, its modular architecture effectively integrates data persistence, search, and optional AI operations. This convenience also raises architectural decisions about where to place embedding generation, model dependencies, and application responsibilities.
Weaviate in Real-World Applications
Weaviate’s published customer stories illustrate how organizations apply vector search to different enterprise requirements:
- Booking.com: Selected Weaviate for its centralized embedding service, supporting search and machine learning workloads across internal teams. Its published case study reports improved performance and about 40% lower costs than its previous solution.
- Kapa.ai: Uses Weaviate as a core component of its AI-powered technical support platform, helping organizations retrieve relevant answers from documentation and knowledge bases.
These examples highlight two architectural requirements: managing large-scale vector infrastructure and building specialized AI-powered applications. They show that vector databases can function as shared enterprise infrastructure or as components of individual products.
However, adding more AI capabilities to the database does not guarantee a better architecture. External embedding generation can provide greater application-level control, while database-managed integrations may simplify development but require additional configuration and provider dependencies. The best approach depends on operational requirements, portability, and how responsibilities are distributed across the system.
For our Java example, we will handle embedding generation within the application using LangChain4j and use Weaviate for vector persistence and retrieval. This separation lets us explore Weaviate’s capabilities through Eclipse JNoSQL without adding extra AI services to the database configuration. Next, run Weaviate locally with Docker and connect it to a lightweight Java SE application.
Setting Up Weaviate With Docker
Weaviate supports multiple deployment options, such as managed cloud services, Docker containers, and Kubernetes clusters. In this article, we will use Docker to run Weaviate locally, enabling us to explore its vector search capabilities without relying on cloud infrastructure or external AI services.
To start Weaviate, use the following command from our example repository:
docker run -d --name weaviate-instance \
-p 8080:8080 -p 50051:50051 \
-e AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED=true \
-e PERSISTENCE_DATA_PATH=/var/lib/weaviate \
-e DEFAULT_VECTORIZER_MODULE=none \
semitechnologies/weaviate:1.38.21
This configuration exposes port 8080 for HTTP and 50051 for gRPC. Automatic vectorization is disabled with DEFAULT_VECTORIZER_MODULE=none because our Java application will generate embeddings using LangChain4j. Anonymous access is enabled for local testing but should not be used in production without proper security controls.
Once Weaviate is running, connect it to Eclipse JNoSQL, which offers a unified persistence abstraction for NoSQL databases. Integration with Jakarta EE and CDI allows developers to use a consistent programming model across REST applications, background services, and batch workloads. For simplicity, our example uses Java SE with CDI and does not require an application server.
The Maven configuration includes the Weaviate driver and LangChain4j to enable local embedding generation:
<dependency>
<groupId>org.eclipse.jnosql.databases</groupId>
<artifactId>jnosql-weaviate</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>
The complete project includes additional dependencies. Next, configure Weaviate using MicroProfile Config in META-INF/microprofile-config.properties:
jnosql.vector.database=products
jnosql.weaviate.host=localhost
jnosql.weaviate.http.port=8080
jnosql.weaviate.grpc.port=50051
The products collection stores the catalog, and the other properties specify the Weaviate endpoints. Unlike previous Milvus and Qdrant examples, this repository does not require specifying a vector dimension or distance metric in the MicroProfile configuration.
With the database configured, we can now demonstrate how Java applications persist objects, generate embeddings, and perform similarity searches using Eclipse JNoSQL.
Exploring Weaviate With Enterprise Java
Once Weaviate is running, we can focus on the application. Eclipse JNoSQL offers VectorTemplate, a Jakarta NoSQL Template specialization that combines standard persistence with vector similarity search. Developers can use familiar Java objects without managing Weaviate’s native API directly.
Returning to our product recommendation example, we can map a product using Jakarta NoSQL annotations:
@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
}
The embedding attribute stores the vector representation, while the other attributes provide structured product information. Since Weaviate’s automatic vectorization is disabled, our Java app
To generate embeddings, we use LangChain4j with a local embedding model and convert its output into Eclipse JNoSQL’s DenseVector:
@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);
}
}
This approach avoids external AI API dependencies while keeping embedding generation independent of the persistence layer. We can then create and insert products using VectorTemplate:
String text = """
Product: %s
Description: %s
""".formatted(name, description);
Vector embedding = embedder.embed(text);
Product product = new Product(
id, name, description, type, embedding);
template.insert(product);
The inserted product includes both business attributes and its numerical representation, which is especially useful for semantic searches.
Semantic Search and Structured Filtering
For example, if a customer searches for “listen to music without cables,” the application generates a query embedding and retrieves similar products without requiring an exact keyword match:
Vector queryVector = embedder.embed(
"listen to music without cables"
);
List<Product> products = template.search(Product.class)
.vector(queryVector)
.limit(Limit.of(3))
.result();
This query can identify relevant products, such as wireless headphones or Bluetooth speakers, even if product descriptions use different terminology.
Enterprise applications often combine semantic retrieval with business constraints. For example, we can restrict the search to electronics:
List<Product> products = template.search(Product.class)
.vector(queryVector)
.where("type").eq(ProductType.ELECTRONICS)
.limit(Limit.of(3))
.result();
Eclipse JNoSQL combines vector similarity with structured conditions, enabling Weaviate to retrieve relevant products within a selected category. This is filtered vector search. Weaviate’s native hybrid features, such as BM25 keyword ranking, are separate capabilities.
Beyond VectorTemplate: Jakarta Data and Jakarta Query
Eclipse JNoSQL supports Java persistence through three complementary specifications: Jakarta NoSQL, Jakarta Data, and Jakarta Query. Jakarta NoSQL provides entity mapping and template operations. Jakarta Data introduces repository abstractions, and Jakarta Query defines a common query language foundation.
For example, Jakarta Data allows developers to express standard persistence operations through a repository:
@Repository
public interface ProductRepository
extends BasicRepository<Product, String> {
}
With a compatible repository provider, this abstraction offers operations such as save(), findById(), and deleteById() without requiring implementation of the underlying persistence logic. Specialized vector searches are still available through VectorTemplate. The repository is an illustrative example and is not included in the supplied Weaviate demo. Jakarta Query integration is a separate, evolving capability.
This combination lets developers choose between standard persistence operations and specialized vector retrieval while maintaining a familiar Java programming model. While Weaviate offers additional AI integrations, our example shows that applications can manage embeddings independently and use the database mainly for persistence and retrieval.
The complete implementation, including the Java SE bootstrap and executable examples, is available in the Eclipse JNoSQL Weaviate demo.
Conclusion
Weaviate offers a flexible solution for building AI-powered search applications by combining vector persistence, hybrid retrieval, and optional AI model integrations. Its modular architecture allows Java developers and software architects to balance application responsibilities, search features, and operational complexity. With Eclipse JNoSQL, we demonstrated integrating Weaviate into enterprise Java using familiar persistence APIs, while maintaining independent embedding generation with LangChain4j. To review the implementation and learn more about polyglot persistence, please visit the Eclipse JNoSQL website for the complete source code.
Opinions expressed by DZone contributors are their own.