Astra Vector DB
Connecting to DataStax Astra Vector DB
To use DataStax Astra DB as a vector database using the JSON API, you have to create a "vector-database" resource in your configuration.yaml file.
If you want to use the CQL based API then you have to create a "astra" resource. See the documentation here.
Required parameters:
token: this is the token provided by the Astra DB service
endpoint: this is the URL of your database
Handling Collections as Assets
You can manage a "collection" in your Astra Database using the "astra-collection" asset type. A collection is a logical container for documents.
With the "astra-collection" asset, you can create a collection in your Astra DB database.
As usual, you can use the creation-mode
and deletion-mode
parameters to control the creation and deletion of the collection.
Querying an Astra DB collection
When you use the "query-vector-db" agent to query Astra, you can use the following parameters:
As usual you can use the '?' symbol as a placeholder for the fields that you specify in the "fields" section. The "id" field is always returned by default, so you don't need to specify it in the "select" list. The "similarity" field is returned depedending on the "include-similarity" parameter, the default is "true". The "vector" field is returned as long as it is it returned by the query, so you don't need to specify it in the "select" list.
The "vector" filter is special, the query uses the "vector" field to perform a similarity search and not an exact match.
Writing to Astra INSERT/UPDATE/DELETE
You can use the query-vector-db
agent to write to Astra and update your collections.
This is an example for the "insertOne" action:
Similarly you can use the "findOneAndUpdate" action to update an existing document:
In delete one or more documents you can use the "deleteOne" and "deleteMany" actions.
This is an example for the "deleteMany" action:
Writing to Astra Vector DB using the "vector-db-sink" agent
When you use the "vector-db-sink" agent to write to Astra, you can use the following parameters:
Set the collection-name to the name of the collection you want to write to. Then you define the fields in the "fields" list. This works similarly to the 'compute' agent, and you can use the same syntax to define the fields.
Configuration
Check out the full configuration properties in the API Reference page.
Last updated