😎 Discover cool tips and tricks for customization in our next Developer Deep Dive virtual event - sign up now!

Fuzzy search on emails not working with wildcard and match operator

5 replies
Last updated: Nov 30, 2020
Hi, i am trying to do a fuzzy search on emails e.g.
email match "*@foo.com"
but it doesn't seem to work with the @. Is there a special escape char?
Nov 30, 2020, 10:04 AM
I've asked the GROQ team about how the wildcard and match operator work, in the meantime you can probably get by with matching against
<http://foo.com|foo.com>
, so
email match "<http://foo.com|foo.com>"
or
email match "*<http://foo.com|foo.com>"
. I'll chime back once I know more though.
Nov 30, 2020, 12:14 PM
I've asked the GROQ team about how the wildcard and match operator work, in the meantime you can probably get by with matching against
<http://foo.com|foo.com>
, so
email match "<http://foo.com|foo.com>"
or
email match "*<http://foo.com|foo.com>"
. I'll chime back once I know more though.
Nov 30, 2020, 12:14 PM
Got some clarification here:
match is a free text search, not a string filtering operator and will not support arbitrary strings with special characters predictably. "<mailto:banana@sanity.io|banana@sanity.io>" will be indexed as ['banan', 'sanity', 'io']. The best way to do what you want here is to match "sanity" and then post-filter your result using a regex on the client side.

Nov 30, 2020, 12:18 PM
We'll try to update the docs about this.
Nov 30, 2020, 12:18 PM
Thanks!
Nov 30, 2020, 12:28 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?