
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou can query multiple _type values using the in operator in GROQ! The syntax looks like this:
*[_type in ["article", "category"]]This will return all documents where the _type is either "article" OR "category". The in operator checks if a value exists in an array, which is exactly what you need for filtering by multiple document types.
Here's a more complete example with a projection:
*[_type in ["post", "page", "product"]]{
_id,
_type,
title,
slug
}This query fetches all documents that are either posts, pages, or products, and returns their ID, type, title, and slug fields.
If you tried using an array directly in the filter like *[_type == ["article", "category"]], that won't work because you're comparing _type to an array rather than checking if it exists within an array. The in operator is the correct way to handle this.
You can also combine this with other filter conditions using the && (AND) or || (OR) operators:
*[_type in ["article", "blogPost"] && publishedAt > "2024-01-01"]The key thing to remember is: use in when you want to check if a field's value matches any value in an array. This is documented in the GROQ pipeline components section, though it can be easy to miss!
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