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
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.datastax.oss.driver.api.core.CqlSession
Cassandra question.protected com.dtsx.astra.sdk.cassio.MetadataVectorTable
Represents an embedding table in Cassandra, it is a table with a vector column. -
Constructor Summary
ConstructorDescriptionCassandraEmbeddingStore
(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.void
Add a new embedding to the store.Add multiple embeddings as a single action.void
Adds multiple embeddings and their corresponding contents that have been embedded to the store.builder()
void
clear()
Delete all rows.void
delete()
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, wait
Methods inherited from interface dev.langchain4j.store.embedding.EmbeddingStore
addAll, findRelevant, findRelevant, findRelevant, generateIds, remove, removeAll, removeAll, removeAll, search
-
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:
add
in 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:
add
in 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:
add
in interfaceEmbeddingStore<TextSegment>
- Parameters:
rowId
- the row idembedding
- representation of the list of floats
-
addAll
Add multiple embeddings as a single action.- Specified by:
addAll
in 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) Description copied from interface:EmbeddingStore
Adds multiple embeddings and their corresponding contents that have been embedded to the store.- Specified by:
addAll
in interfaceEmbeddingStore<TextSegment>
- Parameters:
ids
- A list of IDs associated with the added embeddings.embeddingList
- A list of embeddings to be added to the store.textSegmentList
- A list of original contents that were embedded.
-
findRelevant
public List<EmbeddingMatch<TextSegment>> findRelevant(Embedding embedding, int maxResults, double minScore) Search for relevant.- Specified by:
findRelevant
in 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
-