Bogdan55
Bogdan55

Reputation: 13

Rest API Cassandra ALLOW FILTERING

I have a DataStax Astra database and I have this example for how to get a user with a specific username:

curl --request GET \
    --url https://${ASTRA_DB_ID}-${ASTRA_DB_REGION}.apps.astra.datastax.com/api/rest/v2/keyspaces/${ASTRA_DB_KEYSPACE}/user?where=\{"user_username":\{"$eq":"'+*username_value_here*+'"\}\}' \
    --header "x-cassandra-token: ${ASTRA_DB_APPLICATION_TOKEN}"

And because of Cassandra i don't have the option ALLOW FILTERING:

{"description":"Bad request: org.apache.cassandra.stargate.exceptions.InvalidRequestException: Cannot execute this query as it might involve data filtering and thus may have unpredictable performance. If you want to execute this query despite the performance unpredictability, use ALLOW FILTERING","code":400}

I can't find anywhere how to enable this option in curl command, so the question is how can i write this (if it's possible) or there are better alternatives. Any help is welcomed.

Upvotes: 1

Views: 564

Answers (1)

dwettlaufer
dwettlaufer

Reputation: 378

The REST API does not currently support ALLOW FILTERING but you have some other options.

  • If usernames are unique in your system and you’re able to alter the data model you could make user_username the partition key. This will allow you to query by that column without needing filtering.
  • Another option if you can’t change the data model would be to add an index on user_username. The index will enable you to maintain your existing access patterns while also allowing you to query by the username.

Upvotes: 2

Related Questions