
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe match operator in GROQ isn't designed for pattern matching with special characters like @ - it's actually a full-text search operator that tokenizes text, which means it treats special characters as word separators.
When you have an email like user@foo.com, the match operator tokenizes it into separate terms: ['user', 'foo', 'com']. So the @ symbol is stripped out during indexing, which is why your pattern "*@foo.com" doesn't work as expected.
For domain-based email matching, use string functions or pattern matching:
// This will match emails with foo.com domain (but not perfectly)
*[email match "foo.com"] // Matches because "foo" and "com" are tokens
// More precise: use string functions for exact matching
*[string::split(email, "@")[1] == "foo.com"]For checking if email contains a substring, you can use the in operator:
// Check if email contains the domain
*["@foo.com" in email]For prefix matching on the full string, use string::startsWith():
// Match emails starting with a specific prefix
*[string::startsWith(email, "admin@")]The key takeaway: match is meant for free-text search (like searching article content), not for pattern matching with special characters. For email domain filtering or any exact string pattern matching, you'll want to use GROQ's string functions or comparison operators instead. There's no escape character because the operator fundamentally works differently than regex-style pattern matching.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store