Ordering results by field on my documents does not work

Hi, I have an issue with orderings my documents results by a custom field. I use javascript and when I do:

{ orderings : '[order desc]' }

nothing is happening. In my case the field "order" is a number and if I remove "desc" nothing change. I also tried with a different field but my query always returns the results in the same order.

When I use first_publication_data for ordering my results it's working, but with custom field it's not.

{ orderings : '[document.first_publication_date]' }

Am i missing something ?

Hi Hugo,

Thank you for contributing to the Prismic community.
Well it seems that the first query you are doing is missing the path of the document type such as

{ orderings : '[my.product.price desc]' }

If that is not the issue then can you tell us what is the location of this field that you are trying to order by (an example of one document can be useful)?

For more info about ordering please check this article

Looking forward to your reply,

What is the path of the document type ? I don't get this part.

My document type is called "feed" and the field is called "order", the document path is "feed.order" ?

Then it should be something like
{ orderings : '[my.feed.order desc]' }

please note that it isn’t possible to order the Prismic results based on a field inside of a Group or Slice

1 Like

Thanks it worked ! Using "my-feed.order" worked for me. I was confused because in the document it was not clear to me that "my" needed to be part of the query.

1 Like

You are welcome :wink:
Please don't hesitate to reach to us if you have any other questions.

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