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.addAll(List<Embedding> embeddingList, List<TextSegment> textSegmentList) Add multiple embeddings as a single action.builder()voidclear()Delete all rows.voiddelete()Delete the table.findRelevant(Embedding embedding, int maxResults, double minScore) Search for relevant.findRelevant(Embedding embedding, int maxResults, double minScore, Metadata metadata) Similarity Search ANN based on the embedding.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface dev.langchain4j.store.embedding.EmbeddingStore
findRelevant, findRelevant, findRelevant
-
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. -
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
Add multiple embeddings as a single action.- Specified by:
addAllin interfaceEmbeddingStore<TextSegment>- Parameters:
embeddingList- embeddingstextSegmentList- text segments- Returns:
- list of new row if (same order as the input)
-
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding embedding, int maxResults, double minScore) Search for relevant.- Specified by:
findRelevantin interfaceEmbeddingStore<TextSegment>- Parameters:
embedding- current embeddingsmaxResults- max number of resultminScore- threshold- Returns:
- list of matching elements
-
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
-