Cassandra
Cassandra stores documents in an Apache Cassandra table, or an Astra DB database, and searches it by meaning.
A vector database stores texts so they can be searched by meaning, not just by exact words. That way an agent can find the paragraph of a manual that answers a question even if it uses different words.
When to use it
- Your company already works with Cassandra and wants to use it as a knowledge base.
- You want stored texts to expire after some time.
- You need to combine search by meaning with words that must appear in the text.
Configuration
The Operation field decides what the component does, and the fields and outputs change with your choice:
Add(default): stores in the database the documents it receives in Ingest Data.Search: finds the documents closest to the text in Search Query.Retriever: offers the database as a search engine for another component to use, for example an agent or a question-answering chain.
You need a Cassandra DB credential with your Cassandra database connection details. See Credentials.
| Field | What it does |
|---|---|
| Credential (required) | The Cassandra DB credential with the connection details. |
| Operation | What the component does: Add, Search or Retriever. |
| Ingest Data (required) | With Add. The documents to store, usually those coming out of a text splitter or a file loader. |
| Search Query | With Search. The text to search for. If left empty, nothing is returned. |
| Embedding | The connector where you plug the component that turns texts into numbers to compare them by meaning, such as OpenAI Embeddings. Always use the same one to store and to search. |
| Keyspace (required) | The table’s keyspace, or the namespace if it is Astra DB. |
| Table Name (required) | The table where documents are stored. |
Advanced options
| Field | What it does |
|---|---|
| Number Of Results | How many documents each search returns. Default: 4. |
| TTL Seconds | If set, stored texts are deleted automatically after that time, in seconds. |
| Batch Size | How many documents are stored in each batch. Default: 16. |
| Setup Mode | How the table is set up: Sync (default), Async or Off. |
| Cluster Arguments | Extra cluster connection settings, if whoever runs it gives you any. |
| Enable Body Search | Allows also searching by words in the text with Search Body. It must be on before the table is created. |
| Search Body | Words that must appear in the text of the documents found. |
| Search Type | How to search: Similarity, Similarity with score threshold, MMR (Max Marginal Relevance). Similarity returns the closest; with a threshold, only those above Search Score Threshold; MMR looks for close but varied results. |
| Search Score Threshold | Minimum similarity score, only with the threshold search. Default: 0.0. |
| Search Metadata Filter | Field and value pairs to search only among the documents that match them. |
Output
The outputs depend on Operation:
- Results: with
AddandSearch. WithSearch, the list of documents found, which you can pass to a prompt or an agent. - Vector Store: with
Add. The database, to connect it to components that work with a vector database. - Retriever: with
Retriever. The search engine, to connect it to components that ask for one.
In tool mode, an agent can use the component to search by itself. See Tool Mode.
Example
A telecom company keeps solved incidents in Cassandra so support can find similar cases.
- Add Cassandra with Operation set to
Search, the keyspace and the table. - Connect the same embeddings component they were stored with.
- Type the new incident’s description in Search Query.
Related components
- Recursive Character Text Splitter: cuts documents into pieces before storing them.
- OpenAI Embeddings: converts texts so they can be searched by meaning.