Interface EmbeddingStore<Embedded>
- Type Parameters:
Embedded- The class of the object that has been embedded. Typically, this isTextSegment.
- All Known Implementing Classes:
AbstractAzureAiSearchEmbeddingStore, AbstractAzureCosmosDBNoSqlEmbeddingStore, AbstractElasticsearchEmbeddingStore, AstraDbEmbeddingStore, AzureAiSearchContentRetriever, AzureAiSearchEmbeddingStore, AzureCosmosDbMongoVCoreEmbeddingStore, AzureCosmosDBNoSqlContentRetriever, AzureCosmosDbNoSqlEmbeddingStore, CassandraEmbeddingStore, ChromaEmbeddingStore, CoherenceEmbeddingStore, CouchbaseEmbeddingStore, ElasticsearchContentRetriever, ElasticsearchEmbeddingStore, HibernateEmbeddingStore, InfinispanEmbeddingStore, InMemoryEmbeddingStore, MariaDbEmbeddingStore, MilvusEmbeddingStore, MilvusV2EmbeddingStore, MongoDbEmbeddingStore, OpenSearchEmbeddingStore, OracleEmbeddingStore, PgVectorEmbeddingStore, PineconeEmbeddingStore, QdrantEmbeddingStore, TablestoreEmbeddingStore, VespaEmbeddingStore, WeaviateEmbeddingStore
-
Method Summary
Modifier and TypeMethodDescriptionAdds a given embedding to the store.Adds a given embedding and the corresponding content that has been embedded to the store.voidAdds a given embedding to the store.Adds multiple embeddings to the store.Adds multiple embeddings and their corresponding contents that have been embedded to the store.default voidAdds multiple embeddings and their corresponding contents that have been embedded to the store.default EmbeddingStore<Embedded> addListener(EmbeddingStoreListener listener) Wraps thisEmbeddingStorewith a listening store that dispatches events to the provided listener.default EmbeddingStore<Embedded> addListeners(List<EmbeddingStoreListener> listeners) Wraps thisEmbeddingStorewith a listening store that dispatches events to the provided listeners.generateIds(int n) Generates list of UUID stringsdefault voidRemoves a single embedding from the store by ID.default voidRemoves all embeddings from the store.default voidRemoves all embeddings that match the specifiedFilterfrom the store.default voidremoveAll(Collection<String> ids) Removes all embeddings that match the specified IDs from the store.search(EmbeddingSearchRequest request) Searches for the most similar (closest in the embedding space)Embeddings.
-
Method Details
-
add
-
add
-
add
Adds a given embedding and the corresponding content that has been embedded to the store.- Parameters:
embedding- The embedding to be added to the store.embedded- Original content that was embedded.- Returns:
- The auto-generated ID associated with the added embedding.
-
addAll
-
addAll
Adds multiple embeddings and their corresponding contents that have been embedded to the store.- Parameters:
embeddings- A list of embeddings to be added to the store.embedded- A list of original contents that were embedded.- Returns:
- A list of auto-generated IDs associated with the added embeddings.
-
generateIds
-
addAll
Adds multiple embeddings and their corresponding contents that have been embedded to the store.The lists are positional: the i-th ID, the i-th embedding and the i-th embedded content belong together.
idsandembeddingsmust therefore have the same size, andembedded, when provided, must have that size as well. Anulllist of IDs or embeddings counts as an empty list, so passing embeddings without IDs (or the other way around) is a size mismatch, not an empty input.ValidationUtils.ensureConsistentSizes(List, List, List)implements these rules and should be used by implementations.Passing no embeddings at all (an empty or
nullembeddingstogether with an empty ornullids, and noembeddedcontents) is a no-op: nothing is stored and no exception is thrown.- Parameters:
ids- A list of IDs associated with the added embeddings.embeddings- A list of embeddings to be added to the store.embedded- A list of original contents that were embedded, ornullif they were not provided.- Throws:
IllegalArgumentException- if the sizes of the given lists do not match.
-
remove
Removes a single embedding from the store by ID.- Parameters:
id- The unique ID of the embedding to be removed.
-
removeAll
Removes all embeddings that match the specified IDs from the store.Having nothing to remove is a no-op: an empty or
nullcollection of IDs leaves the store unchanged and throws nothing, in the same way that adding no embeddings stores nothing.- Parameters:
ids- A collection of unique IDs of the embeddings to be removed.
-
removeAll
Removes all embeddings that match the specifiedFilterfrom the store.- Parameters:
filter- The filter to be applied to theMetadataof theTextSegmentduring removal. Only embeddings whoseTextSegment'sMetadatamatch theFilterwill be removed.
-
removeAll
default void removeAll()Removes all embeddings from the store. -
search
Searches for the most similar (closest in the embedding space)Embeddings.
All search criteria are defined inside theEmbeddingSearchRequest.
EmbeddingSearchRequest.filter()can be used to filter by various metadata entries (e.g., user/memory ID). Please note that not allEmbeddingStoreimplementations supportFiltering.- Parameters:
request- A request to search in anEmbeddingStore. Contains all search criteria.- Returns:
- An
EmbeddingSearchResultcontaining all foundEmbeddings.
-
addListener
Wraps thisEmbeddingStorewith a listening store that dispatches events to the provided listener.This is a non-breaking convenience method to add observability to any
EmbeddingStoreimplementation.- Parameters:
listener- The listener to add.- Returns:
- An observing
EmbeddingStorethat will dispatch events to the provided listener. - Since:
- 1.11.0
-
addListeners
Wraps thisEmbeddingStorewith a listening store that dispatches events to the provided listeners.Listeners are called in the order of iteration.
- Parameters:
listeners- The listeners to add.- Returns:
- An observing
EmbeddingStorethat will dispatch events to the provided listeners. - Since:
- 1.11.0
-