# DataStax Solutions

DataStax vector database components provide integration with Astra DB, Cassandra, and HCD (Hyper-Converged Database) for scalable vector storage and retrieval.

## Astra DB Vector Store

This component implements a Vector Store using Astra DB with search capabilities.

For more information, see the [DataStax documentation](https://docs.datastax.com/en/astra-db-serverless/databases/create-database.html).

### Use a vector store component in a flow

This example uses the **Astra DB vector store** component. Your vector store component's parameters and authentication may be different, but the document ingestion workflow is the same. A document is loaded from a local machine and chunked. The Astra DB vector store generates embeddings with the connected [model](../ai-models/openai-models) component, and stores them in the connected Astra DB database.

This vector data can then be retrieved for workloads like Retrieval Augmented Generation.

### Inputs

| Name                         | Display Name                       | Info                                                                                                                                                        |
| ---------------------------- | ---------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| token                        | Astra DB Application Token         | The authentication token for accessing Astra DB.                                                                                                            |
| environment                  | Environment                        | The environment for the Astra DB API Endpoint. For example, `dev` or `prod`.                                                                                |
| database\_name               | Database                           | The database name for the Astra DB instance.                                                                                                                |
| api\_endpoint                | Astra DB API Endpoint              | The API endpoint for the Astra DB instance. This supersedes the database selection.                                                                         |
| collection\_name             | Collection                         | The name of the collection within Astra DB where the vectors are stored.                                                                                    |
| keyspace                     | Keyspace                           | An optional keyspace within Astra DB to use for the collection.                                                                                             |
| embedding\_choice            | Embedding Model or Astra Vectorize | Choose an embedding model or use Astra vectorize.                                                                                                           |
| embedding\_model             | Embedding Model                    | Specify the embedding model. Not required for Astra vectorize collections.                                                                                  |
| number\_of\_results          | Number of Search Results           | The number of search results to return (default: `4`).                                                                                                      |
| search\_type                 | Search Type                        | The search type to use. The options are `Similarity`, `Similarity with score threshold`, and `MMR (Max Marginal Relevance)`.                                |
| search\_score\_threshold     | Search Score Threshold             | The minimum similarity score threshold for search results when using the `Similarity with score threshold` option.                                          |
| advanced\_search\_filter     | Search Metadata Filter             | An optional dictionary of filters to apply to the search query.                                                                                             |
| autodetect\_collection       | Autodetect Collection              | A boolean flag to determine whether to autodetect the collection.                                                                                           |
| content\_field               | Content Field                      | A field to use as the text content field for the vector store.                                                                                              |
| deletion\_field              | Deletion Based On Field            | When provided, documents in the target collection with metadata field values matching the input metadata field value are deleted before new data is loaded. |
| ignore\_invalid\_documents   | Ignore Invalid Documents           | A boolean flag to determine whether to ignore invalid documents at runtime.                                                                                 |
| astradb\_vectorstore\_kwargs | AstraDBVectorStore Parameters      | An optional dictionary of additional parameters for the AstraDBVectorStore.                                                                                 |

### Outputs

| Name            | Display Name   | Info                                                                                                                                       |
| --------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| vector\_store   | Vector Store   | Astra DB vector store instance configured with the specified parameters.                                                                   |
| search\_results | Search Results | The results of the similarity search as a list of [Data](https://github.com/GuidenAI/broxi_document/blob/main/components/data.md) objects. |

### Generate embeddings

The **Astra DB Vector Store** component offers two methods for generating embeddings.

1. **Embedding Model**: Use your own embedding model by connecting an [Embeddings](https://github.com/GuidenAI/broxi_document/blob/main/components/embeddings.md) component.
2. **Astra Vectorize**: Use Astra DB's built-in embedding generation service. When creating a new collection, choose the embeddings provider and models, including NVIDIA's `NV-Embed-QA` model hosted by Datastax.

### Hybrid search

The **Astra DB** component includes **hybrid search**, which is enabled by default.

The component fields related to hybrid search are **Search Query**, **Lexical Terms**, and **Reranker**.

* **Search Query** finds results by vector similarity.
* **Lexical Terms** is a comma-separated string of keywords, like `features, data, attributes, characteristics`.
* **Reranker** is the re-ranker model used in the hybrid search. The re-ranker model is `nvidia/llama-3.2-nv.reranker`.

[Hybrid search](#hybrid-search) performs a vector similarity search and a lexical search, compares the results of both searches, and then returns the most relevant results overall.

## Cassandra

This component creates a Cassandra Vector Store with search capabilities. For more information, see the [Cassandra documentation](https://cassandra.apache.org/doc/latest/cassandra/vector-search/overview.html).

### Inputs

| Name                     | Type         | Description                                            |
| ------------------------ | ------------ | ------------------------------------------------------ |
| database\_ref            | String       | Contact points for the database or AstraDB database ID |
| username                 | String       | Username for the database (leave empty for AstraDB)    |
| token                    | SecretString | User password for the database or AstraDB token        |
| keyspace                 | String       | Table Keyspace or AstraDB namespace                    |
| table\_name              | String       | Name of the table or AstraDB collection                |
| ttl\_seconds             | Integer      | Time-to-live for added texts                           |
| batch\_size              | Integer      | Number of data to process in a single batch            |
| setup\_mode              | String       | Configuration mode for setting up the Cassandra table  |
| cluster\_kwargs          | Dict         | Additional keyword arguments for the Cassandra cluster |
| search\_query            | String       | Query for similarity search                            |
| ingest\_data             | Data         | Data to be ingested into the vector store              |
| embedding                | Embeddings   | Embedding function to use                              |
| number\_of\_results      | Integer      | Number of results to return in search                  |
| search\_type             | String       | Type of search to perform                              |
| search\_score\_threshold | Float        | Minimum similarity score for search results            |
| search\_filter           | Dict         | Metadata filters for search query                      |
| body\_search             | String       | Document textual search terms                          |
| enable\_body\_search     | Boolean      | Flag to enable body search                             |

### Outputs

| Name            | Type        | Description                                                                 |
| --------------- | ----------- | --------------------------------------------------------------------------- |
| vector\_store   | Cassandra   | A Cassandra vector store instance configured with the specified parameters. |
| search\_results | List\[Data] | The results of the similarity search as a list of `Data` objects.           |

## Usage Notes

* **Enterprise Scale**: DataStax solutions provide enterprise-grade scalability and reliability
* **Cloud Native**: Astra DB is a fully managed cloud service
* **Hybrid Deployment**: Cassandra can be deployed on-premises or in hybrid environments
* **Advanced Features**: Support for hybrid search, graph capabilities, and multi-modal data
