Find data with filters
Filters are a foundational way to find data in any database. They are best for matching an exact value or range of values, such as finding a user by their user ID.
In Astra DB Serverless, you can use filters alone or with sorting.
Find data in the Astra Portal
In the Astra Portal, you can use the Data Explorer to apply simple metadata filters to collections in Serverless (Vector) databases.
For Serverless (Non-Vector) databases and tables in Serverless (Vector) databases, you can use the built-in CQL shell to execute CQL statements that use WHERE
and ORDER BY
clauses.
For required permissions, see Ways to find data in Astra DB Serverless.
-
Data Explorer
-
CQL shell
-
In the Astra Portal navigation menu, click Databases, and then click the name of your Serverless (Vector) database.
The Data Explorer isn’t available for Serverless (Non-Vector) databases. Instead, you can use the CQL shell and drivers.
-
Click Data Explorer.
-
Select a Keyspace and Collection.
-
If you selected a vector-enabled collection, click Add Filter. For non-vector collections, the first filter is automatically added.
For vector-enabled collections, you can combine filters with vector search. For more information, see Find data with vector search.
-
For Key, select the field to filter on.
-
For Condition, select a filter condition, such as is or is not. Available filters depend on the Key field’s data type. For more information about filter operators, see Filter operators for collections.
-
For Value, enter the filter value.
Conditions like is, is not, and contains require an exact, case-sensitive match on the Value.
Filter example:
is
For this example, assume that you have the following filter:
-
Key:
character
-
Condition:
is
-
Value:
Lassie
This filter returns all documents where the
character
field is exactlyLassie
. It doesn’t return documents with values likelassie
orLassie Come Home
, which are not exact, case-sensitive matches.Filter example:
is not
For this example, assume that you have the following filter:
-
Key:
color
-
Condition:
is not
-
Value:
red
This filter returns all documents where the
color
field isn’t exactlyred
. However, it can return documents containingRed
andreddish
, which are not exact, case-sensitive matches. -
-
To add more filters, click Add Filter.
Additional filters are appended together with the
and
operator. For other operators, you must use the Data API.To remove a filter, click delete Delete.
-
Click Apply.
The Records section updates based on your filters. Click Table and JSON to view the documents in table format or JSON format.
For information about the built-in CQL shell and executing CQL statements, see Cassandra Query Language (CQL) for Astra DB.
Find data with the Data API
If you’re new to the Data API, try the quickstart for collections or the quickstart for tables for a demo of some common operations. |
With the Data API, you use filter and sort clauses to find data in collections and tables.
Any Data API command that involves finding data accepts one or both of these clauses.
-
Collections
-
Tables
For examples of filter and sort clauses in specific Data API commands, see the reference for the command that you want to run:
For general information about filter operators and sort clauses, see the following:
For examples of filter and sort clauses in specific Data API commands, see the reference for the command that you want to run:
For general information about filter operators and sort clauses, see the following:
Find data with CQL and drivers
Broadly speaking, you use the CQL WHERE
and ORDER BY
clauses to filter and sort data, and there are many ways to create complex CQL statements to find data efficiently.
For information about writing and executing CQL statements, see the following: