Expand my Community achievements bar.

Sorting in Query builder is not working as expected

Avatar

Level 1

I have query builder parameter as

path=/content/sample/en
type=cq:Page
orderby=@jcr:content/jcr:title
orderby.sort=asc
p.limit=-1


Now I have two Pages as
/content/sample/en/sample-page  (jcr:title -> Sample Page)
/content/sample/en/1-page  (jcr:title -> 1 Page)

/content/sample/en/3  (jcr:title -> 3)

/content/sample/en/3-page  (jcr:title -> 3 Page)

Ideally I should get numeric at the top but I am getting order as
/content/sample/en/3  (jcr:title -> 3)

/content/sample/en/3-page  (jcr:title -> 3 Page)

/content/sample/en/sample-page  (jcr:title -> Sample Page)

/content/sample/en/1-page  (jcr:title -> 1 Page)

This is incorrect am I doing something wrong here need guidance from the community

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

2 Replies

Avatar

Level 7

hi @RohanRa6

I've created pages with the same structure as yours:

Screenshot 2025-03-18 at 15.32.51.png

and query results are exactly as expected:

Screenshot 2025-03-18 at 15.35.13.png

You can see on the left a slightly changed query hitting on cq:PaceContent as a reference for comparison (non-suggested though because OOTB there is no index defined already).

The results are as expected so I'm guessing that your sample-page has a number at the beginning of the jcr:title property? 

If not please have a look at General Debugging Recommendations so you can obtain more clarity about the query with Explain Query 

Avatar

Level 7

I've just noticed the same ordering as you with a simple space after jcr:title: not working vs working 

You can see the space char highlighted in blu and pages are sorted by creation date:

Screenshot 2025-03-18 at 15.53.03.png