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 cqlsh
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 Console
-
In the Astra Portal, click the name of your Serverless (Vector) database.
The Data Explorer isn’t available for Serverless (Non-Vector) databases. Instead, you can use the standalone cqlsh or drivers.
-
Click Data Explorer.
-
Select a Keyspace.
-
Select a Collection or Table.
The default search mode depends on the configuration of the collection or table:
-
With vector search: For vector-enabled collections and tables with vector columns, the default search is a vector search. To run a vector search, enter an embedding or text string in the Search field. To combine vector search with metadata filters, click Filters. Astra DB automatically adds an initial filter based on the identifier or primary key. For more information about vector search with or without metadata filters, see Find data with vector search
-
Without vector search: For a non-vector collections and tables without vector columns, Astra DB automatically adds an initial filter based on the identifier or primary key. You can use the default filter, modify it, or click Add Filter to add more filters.
-
-
Edit the default filter or add a new filter, and then define the filter:
-
Key: Select the field or column to filter on.
When searching tables, the Data Explorer only allows you to query indexed columns to prevent queries with
ALLOW FILTERING
, which can be long-running and resource intensive. -
Condition: Select a filter condition, such as is or is not. Available filters depend on the data type of the Key. For more information about filter operators, see Filter operators for collections and Filter operators for tables.
-
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 results in table format or JSON format.
For information about the built-in cqlsh
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: