Dropping an index in your keyspace

Prerequisites

  1. Get an application token.

  2. Create a table in your keyspace.

  3. Create an index in your keyspace.

  4. You may wish to list all the indexes to verify the index name you wish to drop:

  • cURL command (/v2)

  • Result

curl -s --location \
--request GET http://$ASTRA_CLUSTER_ID-$ASTRA_REGION.apps.astra.datastax.com/api/rest/v2/schemas/keyspaces/users_keyspace/tables/users/indexes \
--header "X-Cassandra-Token: $ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
[
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "current_country"
      }
    ],
    "table_name": "users",
    "index_name": "country_idx",
    "kind": "COMPOSITES"
  },
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "entries(evaluations)"
      }
    ],
    "table_name": "users",
    "index_name": "evale_idx",
    "kind": "COMPOSITES"
  },
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "keys(evaluations)"
      }
    ],
    "table_name": "users",
    "index_name": "evalk_idx",
    "kind": "COMPOSITES"
  },
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "values(evaluations)"
      }
    ],
    "table_name": "users",
    "index_name": "evalv_idx",
    "kind": "COMPOSITES"
  },
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "values(favorite_books)"
      }
    ],
    "table_name": "users",
    "index_name": "fav_books_idx",
    "kind": "COMPOSITES"
  },
  {
    "keyspace_name": "users_keyspace",
    "options": [
      {
        "key": "target",
        "value": "values(top_three_tv_shows)"
      }
    ],
    "table_name": "users",
    "index_name": "tv_idx",
    "kind": "COMPOSITES"
  }
]

Dropping an index

Send a DELETE request to /api/rest/v2/schemas/keyspaces/{keyspace_name}/tables/{table_name}/indexes/{index_name} to delete an index. All index data will be deleted along with the index schema.

curl -s --location \
--request DELETE http://$ASTRA_CLUSTER_ID-$ASTRA_REGION.apps.astra.datastax.com/api/rest/v2/schemas/keyspaces/users_keyspace/tables/users/indexes/fav_books_idx \
--header "X-Cassandra-Token: $ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--header "Accept: application/json"

If the call is successful, a 204 message is returned.