Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

AEM Querybuilder sort doesn't work if folder names have numbers

Avatar

Level 3

I have a folder that have some sub-folders named as 8134, 9094 along with only text. The query builder predicate `orderby=@jcr:content/jcr:title` sorts the folder names if there are no numbers in the folder names. But if they do, the sort oder is not correct. What am i missing or doing wrong?

My query:

path=/content/dam/sxm-apps/channel-assets

property=jcr:primaryType

property.1_value=sling:OrderedFolder

property.2_value=sling:Folder

p.limit=-1

p.guesstotal=true

path.flat=true

orderby=@jcr:content/jcr:title

Not sorted if the folder names have numbers in them:

not-sorted.png

Sorted, if the folder names do not have numbers in them:

sorted.png

1 Accepted Solution

Avatar

Correct answer by
Level 5

Hello ksuren

I've checked this query on my end and the only time sorting really breaks for me is if I am actually missing the jcr:title on one of the nodes. For example

The query ran when the jcr:title is missing

BrokenResults.png

The query ran when the jcr:title is available

CorrectResults.png

Can you please confirm that these folders have jcr:title available on them?

Regards,

Aneet

View solution in original post

3 Replies

Avatar

Correct answer by
Level 5

Hello ksuren

I've checked this query on my end and the only time sorting really breaks for me is if I am actually missing the jcr:title on one of the nodes. For example

The query ran when the jcr:title is missing

BrokenResults.png

The query ran when the jcr:title is available

CorrectResults.png

Can you please confirm that these folders have jcr:title available on them?

Regards,

Aneet

Avatar

Level 3

You are right aneeta45259594​ but i found the reason for my issue.

The way folders are setup by customer is that they are using a "friendly name" (jcr:title) for display, while node name is kind of ID so they can identify it (according to their internal legacy database). As below

Screen Shot 2018-06-06 at 2.30.47 PM.png

So i had to change my query sort based on "node name" (orderby=nodename) instead of "jcr:title".

Final query:

path=/content/dam/sxm-apps/channel-assets

property=jcr:primaryType

property.1_value=sling:OrderedFolder

property.2_value=sling:Folder

p.limit=-1

p.guesstotal=true

path.flat=true

orderby=nodename

Avatar

Level 5

That is also correct and since your use-case doesn't actually depend on the particular property and you simply wanted to see the correct order of the folder, you could even use orderby=path to get same results.

Please mark this thread as solved once you evaluate all the possibilities.

Best Regards,

Aneet