Using `match` in GROQ query to search for slugs starting with a specific path
Last updated: Jun 14, 2023
I tried to use
in a GROQ query to get all the slugs that starts with the same path as the current category.
*[slug.current match "/path/something" + "*"]
But this returns some extra documents that has path and something elsewhere in the slug, like /path/different/something-document. So it seems like the slashes do something magic here, but I can’t find any documentation on it. How can I get the documents that start with this slug?
May 19, 2023, 1:31 PM
is for text, and will do tokenization. These will all evaluate to true:
"/something/path" match "/path/something"
"/something/path" match "something something path"
"/something/path" match "path? something!"