Query by UID on multiple documents

We have the following scenario:
content type A: UID, title, …
content type B: UID, title, …
content type C: UID, title, …

All the UIDs are used as URL path.

Is there a way or what is the best way to query by UID on multiple documents?
What I would like to achieve is something similar to OR condition A.uid == ‘something’ OR B.uid == ‘something’

Is there a way to search in all content types (still on UID), but exclude some (search in A and B, excluding C)?

I encountered the exact same issue a shot while ago. As far as I understand the document model of prismic doesn’t allow such a query to be written through the normal API because the uid field despite having a unique name is not accesible on the document predicate, it can only be accessed through the custom type name my.type.uid

what I ended up doing is running multiple queries in // against each of the possible document types, merging the results and returning the first non empty result. in javascript it looks like this :

    async (client, opts) => {
        const docs = await Promise.all([
          client
            .query(
              [
                Prismic.Predicates.at('document.type', 'doctype1')
                Prismic.Predicates.at('my.doctype1.uid', uid)
              ],
              opts
            )
            .then(r => r.results),
          client
            .query(
              [
                Prismic.Predicates.at('document.type', 'doctype2'),
                Prismic.Predicates.at('my.doctype2._uid', uid
              ],
              opts
            )
            .then(r => r.results),
          client
            .query(
              [
                Prismic.Predicates.at('document.type', 'doctype3'),
                Prismic.Predicates.at('my.doctype3.uid', uid)
              ],
              opts
            )
            .then(r => r.results)
        ]);
        return docs.flat().find(x => typeof x !== 'undefined') || null;
      }

That makes me curious : do you only have flat paths ? As far as I am aware you cannot add a / in a uid field which is why we define a custom path field on all our document types to describe the actual path. It feels like some kind of document tree description is missing from prismic where all the documents are in a flat landscape whereas urls can be nested arbitrarily deep …

Thanks Jean.
Same conclusion as myself. Unfortunately, I don’t like at all.

For this case yes, just flat paths. We have 3 different types (for now), the differences are in the fields and layout.

This issue has been closed due to inactivity.