Query by content relationship is not working

Hello :wave:

I have a document in french and the same document in english. (document type static_page)

Let's say the french document has ID french-doc, and let's say the english document has ID english-doc.

Now, in the prismic doc i have a Group of Content Relationship field called alternative_page.

In the french doc i have selected the "english doc" in the Group of Content Relationship field.

My query is:

[:d = at(my.static_page.alternative_page, "english-doc")]

With this query I'm trying to retrive the "french doc".

But I get the following error:

[function at(..)] unexpected field 'my.static_page.alternative_page' on line:1 col:11 in query '[[:d = at(my.static_page.alternative_page, "english-doc")]]'
[[:d = at(my.static_page.alternative_page, "english-doc")]]
^

Please help!

I found a solution.

Not using a Group of Content Relationship field.

Instead adding just a Content Relationship field.

And each child page will point to the parent page.

Instead of: in the parent page pointing all the children pages.


Also, I need to change the query from lang: "fr-fr" to lang: "*"
(source: Document API Technical Reference - Documentation - Prismic).

1 Like

Hey @wakematta,

Thanks for reaching out, and for coming back with a solution! You beat us to it :slight_smile: I hope this helps the next user that runs into this problem.