How do I query for a field value on ALL document types

I have a common field ID on all document types, “category”. It is a select type field. How can I query all of my documents where that field value is equal to “Interview”.

I have tried:

q=[[any(my.exercise.category,“INTERVIEWS”)]]
q=[[any(my.article.category,“INTERVIEWS”)]]

But that doesn’t seem to be doing an OR comparison, and instead an AND comparison.

Any help would be much appreciated.

Thanks

Hey Stefan, welcome to the Prismic community forum!

What you’re stating is correct. That query does an && comparison rather than ||, I added a task in the backlog to make this clearer in our documentation.

You can try and use the Fulltext search instead. This way you can specify exactly what you’re looking for. e.g:

q=[[fulltext(document,"prismic")]]

But then that presents another problem: We end up returning documents where other fields include the word “inverviews”. Is there no way to specify the query for a particular field ID?

1 Like

You are right, the fulltext search will find coincidences in all following fields: Rich Text, Title, Key Text, UID and Select.

In this case, the first option using the at predicate will be the best one, but, you have to consider that this call searches for results only in the specified custom type.

Another option I can recommend you if you need to be able to do a partial search in your proejct is to use a third party search service such as Algolia.

This issue has been closed due to inactivity.