Data API vector collection

Number of APIs: 9

To run Data API commands in Qodex:

  1. In DataStax Astra Portal, create a vector-enabled Astra DB Serverless database. Wait for your database to be Active before continuing.

  2. Define local variables here in Qodex with values specific to your vector-enabled Astra DB Serverless database. In the Data API calls here in Qodex, you'll need the appropriate values for ASTRADBAPPLICATION_TOKEN and the ASTRADBAPI_ENDPOINT.

    1. In Astra Portal, on your database's Overview tab, generate an Application Token; copy and use that value in an ASTRADBAPPLICATION_TOKEN local variable in Qodex.
    2. Also in Astra Portal, copy your API Endpoint from your database's Overview tab; use that value in an ASTRADBAPI_ENDPOINT local variable in Qodex.

      1. An API Endpoint has this format:
        https://{{ASTRADBID}}-{{ASTRADBREGION}}.apps.astra.datastax.com
  3. Also define local variables for an ASTRADBKEYSPACE, and an ASTRADBCOLLECTION name.

    1. An ASTRADBKEYSPACE example: default_keyspace, which is present by default in your vector-enabled database.
    2. An ASTRADBCOLLECTION example: vector_collection
  4. In Qodex, only change the Current value of your local variables. And be sure to Save the local variable definitions.

  5. Download and install the [Qodex app,] if you haven't already.

TIP: Notice in the Data API commands:

  • The fully qualified url path -- before the collection has been created, or when you want to find or delete an existing collection -- is: ASTRADBAPIENDPOINT/api/json/v1/ASTRADBKEYSPACE_

  • Once the collection has been created, the fully qualified url path is: ASTRADBAPIENDPOINT/api/json/v1/ASTRADBKEYSPACE/ASTRADBCOLLECTION_

After stepping through all the commands, you can reset the example data and start over by executing the final call, deleteCollection.

About local variables: Here's an example of the local Variables UI in Qodex (with redacted ID values) for a vector-enabled Astra DB Serverless database:

Example%20of%20local%20variables%20associated%20with%20existing%20Astra%20DB%20Serverless%20database
  1. Create and find collections - findCollections POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}

  2. Insert data - insertMany documents with $vector POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_COLLECTION}}

  3. Update data - updateMany - Set element value POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_COLLECTION}}

  4. Delete data - deleteMany - delete by status POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_COLLECTION}}

  5. Delete data - deleteCollection - delete by collection name, vectorize POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}

  6. Find and modify data - findOneAndDelete with $vectorize POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_COLLECTION}}

  7. Insert data - insertMany documents with $vectorize POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_VECTORIZE_COLLECTION}}

  8. Find data - find sorted by $vectorize search, projection enabled, return similarity scores POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_VECTORIZE_COLLECTION}}

  9. Find data - find with pagingState: to get all purchases showing Page 2 results POST {{ASTRA_DB_API_ENDPOINT}}/api/json/v1/{{ASTRA_DB_KEYSPACE}}/{{ASTRA_DB_COLLECTION}}