See how we built our intranet. Live + Q&A, June 30

Query posts with specific author in second position of multiple authors

19 repliesLast updated: Nov 29, 2025

Lets say i have "Posts" and i have "Authors" which is multiple authors for a post. Is it possible to do a query for "Give me all posts that are written by more than one author, where Chris is the second author" (as mentioned in the"shoptalkshow") ? What does that query look like ?
AI Update

Yes! This is absolutely possible in GROQ. You can access array elements by their index position and filter on specific positions within an array.

Here's how you would write that query:

*[_type == "post" && count(authors) > 1 && authors[1]->name == "Chris"]

Let me break down what's happening:

If you want to return specific fields from the matching posts, you can add a projection:

*[_type == "post" && count(authors) > 1 && authors[1]->name == "Chris"]{
  title,
  authors[]->{name}
}

A few important notes:

If your authors array contains objects rather than references, you'd adjust slightly:

*[_type == "post" && count(authors) > 1 && authors[1].name == "Chris"]

This pattern works for any array position - just change the index number to match the position you're interested in!

Show original thread
19 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.

Related contributions