|
This version is still in development and is not considered stable yet. For the latest stable version, please use Spring AI 2.1.0! |
Oracle Coherence
This page describes how to use Oracle Coherence 24.09 or later as a VectorStore.
The CoherenceVectorStore supports:
-
Vectors with unspecified or fixed dimensions.
-
A configurable distance type for similarity search.
-
Vector indexes, either HNSW or binary quantization.
-
Exact and approximate similarity search.
-
Metadata filter expressions.
Dependency
Add the Coherence vector store module to your project:
-
Maven
-
Gradle
<dependency>
<groupId>org.springframework.ai</groupId>
<artifactId>spring-ai-coherence-store</artifactId>
</dependency>
dependencies {
implementation 'org.springframework.ai:spring-ai-coherence-store'
}
| Refer to Dependency Management to add the Spring AI BOM to your build file. |
Spring AI does not provide a Spring Boot starter or auto-configuration for this store.
You create the CoherenceVectorStore bean yourself.
Manual Configuration
The store needs a Coherence Session and an EmbeddingModel:
@Bean
public VectorStore vectorStore(Session session, EmbeddingModel embeddingModel) {
return CoherenceVectorStore.builder(session, embeddingModel)
.mapName("spring-ai-documents")
.distanceType(CoherenceVectorStore.DistanceType.COSINE)
.indexType(CoherenceVectorStore.IndexType.HNSW)
.build();
}
| Builder method | Description | Default |
|---|---|---|
|
The name of the Coherence map that holds the documents. |
|
|
The distance used for similarity search: |
|
|
The vector index: |
|
|
Whether vectors are normalized when they are ingested.
A similarity threshold can be used only with the |
|
Accessing the Native Client
The Coherence Vector Store implementation provides access to the underlying native Coherence client (Session) through the getNativeClient() method:
CoherenceVectorStore vectorStore = context.getBean(CoherenceVectorStore.class);
Optional<Session> nativeClient = vectorStore.getNativeClient();
if (nativeClient.isPresent()) {
Session session = nativeClient.get();
// Use the native client for Coherence-specific operations
}
The native client gives you access to Coherence-specific features and operations that might not be exposed through the VectorStore interface.