Is the GROQ `match` operator case-sensitive?
matchquery operator case-sensitive? i.e. is
*[text match "word"] *[text match "wORd"] Yes, the match operator in GROQ is case-insensitive. So *[text match "word"] and *[text match "wORd"] will return the same results.
This is confirmed in a Sanity community answer where a Sanity team member explicitly states that the match operator is not case-sensitive.
The match operator is designed for full-text search and uses tokenization to break down text into searchable terms. When you use match, both your search term and the field being searched are tokenized and compared in a case-insensitive manner. This makes it ideal for human-language text searches where you want to find content regardless of capitalization.
When case matters
If you need case-sensitive matching, you should use different approaches:
- For exact string comparisons: Use the equality operator
== - For prefix matching: Use
string::startsWith()which is case-sensitive - For substring checks: Use the
inoperator or string functions
Example
// Case-insensitive (all return same results)
*[title match "Demo"]
*[title match "demo"]
*[title match "DEMO"]
// Case-sensitive alternatives
*[title == "Demo"] // Only matches exact case
*[lower(title) == "demo"] // Normalize to lowercase firstThe case-insensitivity of match makes it particularly useful for search features where users might type queries in any combination of upper and lowercase letters.
Show original thread2 replies
Was this answer helpful?
Sanity – Build the way you think, not the way your CMS thinks
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.