OR query with multiple predicates

Hi all!
Is there a way to perform a OR query using predicates? Let’s say I have a category field which is a content relationship, and a subcategory field which is also a content relationship. How would you query all articles that have category=xyz OR subcategory=xyz ? seems like the only solution is to perform 2 calls in parallel and merge the responses together.

Thanks!
Simon

Hi @unlikelystudio, thanks for reaching out about this.

Unfortunately as you've discovered there is no way currently to do this sort of query. The only workaround is the one you suggested: making 2 separate queries and combining the results.

I've submitted this to our Product team as a feature request to possibly work on in the future. There is no guarantee this feature will be implemented, though. Your post ensures that the idea is put on the table and discussed. If/when we have information to communicate about this idea, we will do it here in this thread.

Thanks again for your feedback :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

@Levi Do you mind creating a real-life scenario of how would that look like in React/Nextjs?

We can concatenate the results easily, but when we need to do pagination, this becomes a bit more complicated.

Thanks,
Kris

Hey Kris,

We don't have any code examples of this at the minute. When Levi gets back from vacation we'll discuss getting an example ready for you.

Thanks.

Hi Kris,

Sorry about the long delay, the vacation season made getting information difficult.

So I talked with Levi and the trick here would be to get all the results for both your queries when you query the documents. So instead of just 20 of each, you would get everything and then concatenate the results.

From there with your new result list, you would build your own pagination in your application. Unfortunately, I don't have any direct code examples for this, but here is a React project that includes pagination that might help :slight_smile:

Thanks.