
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThe match operator isn't the right tool for prefix matching! You're experiencing this issue because match is designed for full-text search, not exact pattern matching. It tokenizes both your search term and the field being searched, treating special characters like slashes as word separators.
When you use *[slug.current match "/path/something" + "*"], the match operator breaks your slug into tokens like ['path', 'something'] and matches any document containing those words anywhere in the slug - which is why you're getting /path/different/something-document in your results.
string::startsWith()For checking if a slug starts with a specific path, use the GROQ string function string::startsWith():
*[_type == "yourType" && string::startsWith(slug.current, "/path/something")]{
slug
}This will only match documents where slug.current literally begins with "/path/something", giving you exact prefix matching without any tokenization.
match Doesn't Work HereAs explained in the match operator article, the match operator tokenizes text based on word boundaries and special characters. Characters like /, @, and . are treated as word separators. So /something/path would be indexed as ['something', 'path'], which is why you're getting unexpected matches.
This tokenization behavior makes match great for free-text search (like searching blog post content), but not suitable for exact string operations like prefix matching on structured strings like slugs or paths.
If string::startsWith() doesn't fit your needs, you can also:
in operator with path() for more complex path matching patterns, as shown in the GROQ Functions Referencestring::split() to break apart the slug and compare individual segmentsThe Query Cheat Sheet has more examples of string functions and filtering techniques if you need other string operations.
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