# Using Your Own Embeddings in Spring AI 2.1

DevFeed: [Using Your Own Embeddings in Spring AI 2.1](<https://devfeed.tech/articles/using-your-own-embeddings-in-spring-ai-2-1-106228.md>)

Original publisher: [Read original article](<https://spring.io/blog/2026/10/28/spring-ai-upsert-own-embeddings>)

Author: sobychacko

Published: 2026-10-28T00:00:00Z

Content type: article

Language: en

Sources: [Spring](<https://devfeed.tech/sources/spring.md>)

Topics: [Spring AI](<https://devfeed.tech/topics/spring-ai.md>), [Embeddings](<https://devfeed.tech/topics/embeddings.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [audio](<https://devfeed.tech/tags/audio.md>), [batch](<https://devfeed.tech/tags/batch.md>), [batch-api](<https://devfeed.tech/tags/batch-api.md>), [boot](<https://devfeed.tech/tags/boot.md>), [cloud](<https://devfeed.tech/tags/cloud.md>), [database](<https://devfeed.tech/tags/database.md>), [database-migration](<https://devfeed.tech/tags/database-migration.md>), [embedding](<https://devfeed.tech/tags/embedding.md>), [embedding-model](<https://devfeed.tech/tags/embedding-model.md>), [embeddings](<https://devfeed.tech/tags/embeddings.md>), [event-driven](<https://devfeed.tech/tags/event-driven.md>), [ids](<https://devfeed.tech/tags/ids.md>), [image](<https://devfeed.tech/tags/image.md>), [images](<https://devfeed.tech/tags/images.md>), [indexing](<https://devfeed.tech/tags/indexing.md>), [java](<https://devfeed.tech/tags/java.md>), [metadata](<https://devfeed.tech/tags/metadata.md>), [microservices](<https://devfeed.tech/tags/microservices.md>), [multimodal](<https://devfeed.tech/tags/multimodal.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [search](<https://devfeed.tech/tags/search.md>), [searching](<https://devfeed.tech/tags/searching.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [spring](<https://devfeed.tech/tags/spring.md>), [spring-ai](<https://devfeed.tech/tags/spring-ai.md>), [text-embeddings](<https://devfeed.tech/tags/text-embeddings.md>), [vectors](<https://devfeed.tech/tags/vectors.md>), [video](<https://devfeed.tech/tags/video.md>), [web-applications](<https://devfeed.tech/tags/web-applications.md>)

## AI overview

Spring AI 2.1 adds `upsert` for storing documents with application-supplied embeddings and a `similaritySearch` overload that accepts a query vector, bypassing the vector store's configured embedding model. This supports multimodal search, such as matching text queries to product photos, and reuse of existing text embeddings. Use a compatible model for indexed content and queries, configure dimensions to match the store, and keep stable document IDs so upserts replace records. Documents must still provide persistable text, metadata, and vectors; media itself remains external. The APIs are opt-in and throw `UnsupportedOperationException` in stores that do not implement them. As of Spring AI 2.1.0-RC1, PGvector, Redis, Elasticsearch, Qdrant, and OpenSearch support both operations. Writes in one upsert call are not guaranteed transactional; Redis also requires a readable or configured expected dimension to prevent invalid-sized vectors from being saved but omitted from search.

## Source excerpt

VectorStore.add() takes text documents, generates embeddings with the store's configured model, and saves both. Spring AI 2.1 adds upsert for applications that already have embeddings or generate them from images, video, or audio. It accepts documents paired with application-supplied vectors, without calling the store's embedding model. A new similaritySearch overload also accepts a query embedding, giving applications control over both indexing and searching. When to supply your own embeddings Let's look at a real-world example. Consider a furniture catalog with a product listed as "Armchair, model A42". Its photo shows green velvet upholstery and wooden legs, but a search for "green velvet armchair" could miss it if those details are absent from the description. A multimodal embedding model produces image and text embeddings that can be compared directly, letting the search match the customer's words to the photo. The application stores photo embeddings with upsert, then embeds search text with the same model to find the closest matches. Video or audio search works similarly if the model supports comparing that content with text queries. For example, store an embedding for a training video segment about replacing a filter (04:00 to 04:30), with the video URL and start and end times in metadata. A search for "how to replace the filter" can then return a result that the application opens at 04:00. Existing text embeddings benefit too, whether they come from a provider's batch API, another team, or a database migration. add() would generate them again. Writing directly to the database avoids that, but requires matching Spring AI's field names and formats for IDs, text, metadata, and vectors so it can read and search the records. upsert handles that storage format for you. Indexing product images For the furniture catalog, let's assume that we are using Spring AI's VertexAiMultimodalEmbeddingModel, which supports text, images, and video. The examples below use these t