Spring AI
Use Spring AI with Oracle AI Database to store embeddings, run similarity searches, and persist chat memory from Spring Boot applications.
Spring AI provides abstractions for AI application development in the Spring ecosystem. The Oracle vector store integration implements the Spring AI VectorStore interface, and Spring AI JDBC chat memory can persist conversation context in Oracle AI Database.
Why Spring AI with Oracle AI Database
Oracle AI Database can store application data, metadata, vectors, and chat memory in one database. Spring AI applications can use this capability for retrieval-augmented generation, semantic search, document search, and contextual chat workflows.
Key capabilities of the integration:
- Vector storage: Store Spring AI document embeddings in Oracle AI Database.
- Similarity search: Query documents by semantic similarity through the Spring AI
VectorStoreinterface. - Metadata filtering: Filter vector search results with Spring AI portable metadata filter expressions.
- Chat memory: Persist selected conversation messages through Spring AI JDBC chat memory.
- Schema initialization: Let the vector store create the required schema when the application starts.
- Index control: Configure exact search, IVF indexes, or HNSW indexes for vector search workloads.
- Spring Boot configuration: Configure the Oracle vector store with application properties or a Java bean.
Architecture
A typical Spring AI and Oracle AI Database application follows this flow:
- Add dependencies: Add the Spring AI Oracle vector store starter and an embedding model starter.
- Configure the data source: Set the Oracle JDBC URL, user name, and password.
- Configure vector settings: Set dimensions, distance type, index type, and schema initialization.
- Inject the vector store: Autowire
VectorStoreor create anOracleVectorStorebean. - Add documents: Create Spring AI
Documentinstances and add them to the vector store. - Search documents: Run similarity searches, optionally with metadata filters.
- Persist chat memory: Configure JDBC chat memory when chat applications need conversation context across calls.
Integration Components
Use the following Spring AI components with Oracle AI Database.
| Component | Use |
|---|---|
spring-ai-starter-vector-store-oracle |
Spring Boot starter for the Oracle vector store. |
OracleVectorStore |
Oracle implementation of the Spring AI VectorStore interface. |
EmbeddingModel |
Spring AI embedding abstraction used to generate vectors for documents and queries. |
SearchRequest |
Search request builder for query text, result count, similarity threshold, and metadata filters. |
FilterExpressionBuilder |
Programmatic builder for portable metadata filter expressions. |
ChatMemory |
Spring AI abstraction for selected messages that provide conversation context. |
JdbcChatMemoryRepository |
JDBC-backed repository that can persist chat memory in Oracle AI Database. |
Resources
- Spring AI Oracle vector store documentation: Source reference for the Oracle vector store integration.
- Spring AI chat memory documentation: Source reference for Spring AI chat memory.
- Spring AI reference documentation: Official Spring AI reference documentation.
- Oracle AI Vector Search documentation: Oracle vector search capabilities.
- Oracle AI Developer Hub: Notebooks, applications, and reference materials.