Cassandra
CassandraVectorStore #
Bases: BasePydanticVectorStore
Cassandra Vector Store.
An abstraction of a Cassandra table with vector-similarity-search. Documents, and their embeddings, are stored in a Cassandra table and a vector-capable index is used for searches. The table does not need to exist beforehand: if necessary it will be created behind the scenes.
All Cassandra operations are done through the CassIO library.
Note: in recent versions, only table
and embedding_dimension
can be
passed positionally. Please revise your code if needed.
This is to accommodate for a leaner usage, whereby the DB connection
is set globally through a cassio.init(...)
call: then, the DB details
are not to be specified anymore when creating a vector store, unless
desired.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table |
str
|
table name to use. If not existing, it will be created. |
required |
embedding_dimension |
int
|
length of the embedding vectors in use. |
required |
session |
(optional, Session)
|
the Cassandra session to use. Can be omitted, or equivalently set to None, to use the DB connection set globally through cassio.init() beforehand. |
None
|
keyspace |
str
|
name of the Cassandra keyspace to work in Can be omitted, or equivalently set to None, to use the DB connection set globally through cassio.init() beforehand. |
None
|
ttl_seconds |
(optional, int)
|
expiration time for inserted entries. Default is no expiration (None). |
None
|
insertion_batch_size |
(optional, int)
|
how many vectors are inserted concurrently, for use by bulk inserts. Defaults to 20. |
DEFAULT_INSERTION_BATCH_SIZE
|
Examples:
pip install llama-index-vector-stores-cassandra
from llama_index.vector_stores.cassandra import CassandraVectorStore
vector_store = CassandraVectorStore(
table="cass_v_table", embedding_dimension=1536
)
Source code in llama-index-integrations/vector_stores/llama-index-vector-stores-cassandra/llama_index/vector_stores/cassandra/base.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
add #
add(nodes: List[BaseNode], **add_kwargs: Any) -> List[str]
Add nodes to index.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes |
List[BaseNode]
|
List[BaseNode]: list of node with embeddings |
required |
Source code in llama-index-integrations/vector_stores/llama-index-vector-stores-cassandra/llama_index/vector_stores/cassandra/base.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
delete #
delete(ref_doc_id: str, **delete_kwargs: Any) -> None
Delete nodes using with ref_doc_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_doc_id |
str
|
The doc_id of the document to delete. |
required |
Source code in llama-index-integrations/vector_stores/llama-index-vector-stores-cassandra/llama_index/vector_stores/cassandra/base.py
192 193 194 195 196 197 198 199 200 201 202 203 |
|
query #
query(query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult
Query index for top k most similar nodes.
Supported query modes: 'default' (most similar vectors) and 'mmr'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
VectorStoreQuery
|
the basic query definition. Defines: mode (VectorStoreQueryMode): one of the supported modes query_embedding (List[float]): query embedding to search against similarity_top_k (int): top k most similar nodes mmr_threshold (Optional[float]): this is the 0-to-1 MMR lambda. If present, takes precedence over the kwargs parameter. Ignored unless for MMR queries. |
required |
Args for query.mode == 'mmr' (ignored otherwise): mmr_threshold (Optional[float]): this is the 0-to-1 lambda for MMR. Note that in principle mmr_threshold could come in the query mmr_prefetch_factor (Optional[float]): factor applied to top_k for prefetch pool size. Defaults to 4.0 mmr_prefetch_k (Optional[int]): prefetch pool size. This cannot be passed together with mmr_prefetch_factor
Source code in llama-index-integrations/vector_stores/llama-index-vector-stores-cassandra/llama_index/vector_stores/cassandra/base.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|