Class CassandraEmbeddingStore
java.lang.Object
dev.langchain4j.store.embedding.cassandra.CassandraEmbeddingStore
- All Implemented Interfaces:
EmbeddingStore<TextSegment>
Implementation of
EmbeddingStore using Cassandra.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.datastax.oss.driver.api.core.CqlSessionCassandra question.protected com.dtsx.astra.sdk.cassio.MetadataVectorTableRepresents an embedding table in Cassandra, it is a table with a vector column. -
Constructor Summary
ConstructorsConstructorDescriptionCassandraEmbeddingStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName, int dimension) Embedding Store.CassandraEmbeddingStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName, int dimension, com.dtsx.astra.sdk.cassio.CassandraSimilarityMetric metric) Embedding Store. -
Method Summary
Modifier and TypeMethodDescriptionAdd a new embedding to the store.add(@NonNull Embedding embedding, TextSegment textSegment) Add a new embedding to the store.voidAdd a new embedding to the store.Add multiple embeddings as a single action.voidbuilder()voidclear()Delete all rows.voiddelete()Delete the table.findRelevant(Embedding embedding, int maxResults, double minScore) findRelevant(Embedding embedding, int maxResults, double minScore, Metadata metadata) Similarity Search ANN based on the embedding.com.datastax.oss.driver.api.core.CqlSessionsearch(EmbeddingSearchRequest request) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface EmbeddingStore
addAll, generateIds, remove, removeAll, removeAll, removeAll
-
Field Details
-
embeddingTable
protected com.dtsx.astra.sdk.cassio.MetadataVectorTable embeddingTableRepresents an embedding table in Cassandra, it is a table with a vector column. -
cassandraSession
protected com.datastax.oss.driver.api.core.CqlSession cassandraSessionCassandra question.
-
-
Constructor Details
-
CassandraEmbeddingStore
public CassandraEmbeddingStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName, int dimension) Embedding Store.- Parameters:
session- cassandra SessiontableName- table namedimension- dimension
-
CassandraEmbeddingStore
public CassandraEmbeddingStore(com.datastax.oss.driver.api.core.CqlSession session, String tableName, int dimension, com.dtsx.astra.sdk.cassio.CassandraSimilarityMetric metric) Embedding Store.- Parameters:
session- cassandra SessiontableName- table namedimension- dimensionmetric- metric
-
-
Method Details
-
delete
public void delete()Delete the table. -
clear
public void clear()Delete all rows. -
getCassandraSession
public com.datastax.oss.driver.api.core.CqlSession getCassandraSession() -
builder
-
builderAstra
-
add
Add a new embedding to the store. - the row id is generated - text and metadata are not stored- Specified by:
addin interfaceEmbeddingStore<TextSegment>- Parameters:
embedding- representation of the list of floats- Returns:
- newly created row id
-
add
Add a new embedding to the store. - the row id is generated - text and metadata coming from the text Segment- Specified by:
addin interfaceEmbeddingStore<TextSegment>- Parameters:
embedding- representation of the list of floatstextSegment- text content and metadata- Returns:
- newly created row id
-
add
Add a new embedding to the store.- Specified by:
addin interfaceEmbeddingStore<TextSegment>- Parameters:
rowId- the row idembedding- representation of the list of floats
-
addAll
Add multiple embeddings as a single action.- Specified by:
addAllin interfaceEmbeddingStore<TextSegment>- Parameters:
embeddingList- embeddings list- Returns:
- list of new row if (same order as the input)
-
addAll
public void addAll(List<String> ids, List<Embedding> embeddingList, List<TextSegment> textSegmentList) - Specified by:
addAllin interfaceEmbeddingStore<TextSegment>
-
search
- Specified by:
searchin interfaceEmbeddingStore<TextSegment>
-
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding embedding, int maxResults, double minScore) -
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding embedding, int maxResults, double minScore, Metadata metadata) Similarity Search ANN based on the embedding.- Parameters:
embedding- vectormaxResults- max number of resultsminScore- score minScoremetadata- map key-value to build a metadata filter- Returns:
- list of matching results
-