Class HanaCloudVectorStore
java.lang.Object
org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
org.springframework.ai.vectorstore.hanadb.HanaCloudVectorStore
- All Implemented Interfaces:
Consumer<List<Document>>,DocumentWriter,VectorStore,VectorStoreRetriever
The SAP HANA Cloud vector engine offers multiple use cases in AI scenarios.
Recent advances in Generative AI (GenAI) and Large Language Models (LLM) have led to
increased awareness of and popularity for vector databases. Similarity search, a key
functionality of vector databases, complements traditional relational databases as well
as full-text search systems. Using natural language text as an example, embedding
functions map data to high dimensional vectors to preserve their semantic similarity.
Developers can then use vector-based semantic search to find similarity between
different passages of text. Because the data within an LLM is current only up to a
specific point in time, vector databases can offer additional relevant text to make
searches more accurate – known as Retrieval Augmented Generation (RAG).
Therefore, the addition of RAG to an LLM using a vector database like SAP HANA Cloud
provides an effective approach to increase the quality of responses from an LLM.
The SAP HANA Cloud vector engine supports the create, read, update, and delete (CRUD)
operations involving vectors using SQL.
HanaCloudVectorStore is an implementation of
org.springframework.ai.vectorstore.VectorStore interface that provides
implementation of COSINE_SIMILARITY function introduced in HanaDB in Mar,
2024
Hana DB introduced a new datatype REAL_VECTOR that can store embeddings
generated by org.springframework.ai.embedding.EmbeddingModel- Since:
- 1.0.0
- Author:
- Rahul Mittal, Christian Tzolov, Sebastien Deleuze, Soby Chacko
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for creatingHanaCloudVectorStoreinstances. -
Field Summary
Fields inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
batchingStrategy, embeddingModel -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedProtected constructor that accepts a builder instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic HanaCloudVectorStore.Builderbuilder(HanaVectorRepository<? extends HanaVectorEntity> repository, EmbeddingModel embeddingModel) Creates a new builder for configuring and creating HanaCloudVectorStore instances.createObservationContextBuilder(String operationName) Create a newVectorStoreObservationContext.Builderinstance.voidPerform the actual add operation.voidPerform the actual delete operation.doSimilaritySearch(SearchRequest request) Perform the actual similarity search operation.intsimilaritySearch(String query) Retrieves documents by query embedding similarity using the defaultSearchRequest's search criteria.Methods inherited from class org.springframework.ai.vectorstore.observation.AbstractObservationVectorStore
add, delete, delete, doDelete, similaritySearchMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.document.DocumentWriter
writeMethods inherited from interface org.springframework.ai.vectorstore.VectorStore
accept, delete, getName, getNativeClient
-
Constructor Details
-
HanaCloudVectorStore
Protected constructor that accepts a builder instance. This is the preferred way to create new HanaCloudVectorStore instances.- Parameters:
builder- the configured builder instance
-
-
Method Details
-
builder
public static HanaCloudVectorStore.Builder builder(HanaVectorRepository<? extends HanaVectorEntity> repository, EmbeddingModel embeddingModel) Creates a new builder for configuring and creating HanaCloudVectorStore instances.- Returns:
- a new builder instance
-
doAdd
Description copied from class:AbstractObservationVectorStorePerform the actual add operation.- Specified by:
doAddin classAbstractObservationVectorStore- Parameters:
documents- the documents to add
-
doDelete
Description copied from class:AbstractObservationVectorStorePerform the actual delete operation.- Specified by:
doDeletein classAbstractObservationVectorStore- Parameters:
idList- the list of document IDs to delete
-
purgeEmbeddings
public int purgeEmbeddings() -
similaritySearch
Description copied from interface:VectorStoreRetrieverRetrieves documents by query embedding similarity using the defaultSearchRequest's search criteria.- Parameters:
query- Text to use for embedding similarity comparison.- Returns:
- Returns a list of documents that have embeddings similar to the query text embedding.
-
doSimilaritySearch
Description copied from class:AbstractObservationVectorStorePerform the actual similarity search operation.- Specified by:
doSimilaritySearchin classAbstractObservationVectorStore- Parameters:
request- the search request- Returns:
- the list of documents that match the query request conditions
-
createObservationContextBuilder
Description copied from class:AbstractObservationVectorStoreCreate a newVectorStoreObservationContext.Builderinstance.- Specified by:
createObservationContextBuilderin classAbstractObservationVectorStore- Parameters:
operationName- the operation name- Returns:
- the observation context builder
-