Faster user search, and filters on your metadata
- Category
- Product
- Published
User search is faster on large applications, and you can now filter users by their metadata.
User search is faster on large applications, and you can now filter users by their metadata.
- Search runs on a new search index: every search in the Dashboard, and the slowest searches from your backend.
- Metadata filters work in the Dashboard and from your backend.
Faster search on large applications
Over the past year we shipped incremental optimizations to user search, but some queries stayed slow. We've now built a dedicated search index. At peak traffic, a query to the index takes a median of 19 milliseconds, and 99% of queries take under 250 milliseconds.
From your backend, we now serve the searches that would be slowest in our main database from the index. These are mostly partial-match searches on large applications. We serve their counts from the index too: counting the matches of a search on a large application could time out after 10 seconds, and those counts now return. Other searches still run in our main database, as fast as they did before. Over time, we'll serve more searches from the index.
The Users page in the Dashboard reads from the new index for every search, filter, and page. It also has these changes:
- Results appear without waiting for the total. A search or filter counts its matches up to 1,000 and shows 1,000+ beyond that.
- Search no longer needs at least three characters.
Filter users by metadata
Metadata is where you keep your own data about a user, like a plan, a customer ID from your billing system, or an internal flag. Until now you could store that data on a user but not search by it.
The Dashboard Users page has a new Metadata filter. Choose public, private, or unsafe metadata, enter a key, and filter for users whose value for that key is or is not the one you enter. With an empty value, is matches users who have the key, and is not matches users who don't. You can combine several conditions in one filter.
As you type a key, the Dashboard suggests keys from the metadata your users already have, including nested keys such as onboarding.completed, with the number of users who have each one. On large applications, those numbers come from a sample of 5,000 users.
See Filter users by metadata for the steps.
How to get it
The faster search and the Metadata filter are live now for every application. Your existing Backend API calls and SDK methods get the faster search with no changes.
To filter by metadata from your backend, or to skip the total, upgrade to @clerk/backend v3.32.0 or clerk-sdk-go v2.10.0. They add two methods:
getUserListWithoutCount()anduser.ListWithoutCountreturn the same page of users asgetUserList()anduser.List, without the total. The existing methods return an exact total with every page and wait for it, and over many users that total can take much longer than the page. Use these when you don't need the total.searchUsers()anduser.Searchaccept metadata filters and page by cursor, so they also suit exports and syncs that read every user. Their results can trail a recent change by a short time.
const { data, cursor } = await clerkClient.users.searchUsers({
metadata: [{ scope: 'public', key: 'plan', match: 'equals', value: 'pro' }],
})page, err := user.Search(ctx, &user.SearchParams{
Metadata: []user.SearchMetadataFilter{
{Scope: "public", Key: "plan", Match: "equals", Value: clerk.String("pro")},
},
})