0
votes

I m trying to sort the AEM query builder search results based on particular value of particular property. as we have in any database like MySQL we can sort based on column's value as well (for exp. ORDER BY FIELD('columnName','anyColumnName'). can we have something like this in AEM.

Suppose we have 5 Assets under path /content/dam/Assets.

Asset Name------------dc:title

1.jpg------------------Apple

2.jpg------------------Cat

3.jpg------------------Cat

4.jpg------------------Ball

5.jpg------------------Drag

I need assets on top of the results where dc:title = cat and also need other results also in sorting asc. expected result as given below

2.jpg------------------Cat

3.jpg------------------Cat

1.jpg------------------Apple

4.jpg------------------Ball

5.jpg------------------Drag

Note:- Using version AEM 6.2

1

1 Answers

0
votes

You can use the orderby predicate with a value of @jcr:content/metadata/dc:title to sort by dc:title with the QueryBuilder. /libs/cq/search/content/querydebug.html is an interface to test queries on your instance. ACS Commons has a good breakdown of all out of the box predicates

If you want to pull Cats to the top of the results with a single query, you could write a custom predicate. The sample code from ACS Commons shows an example. Adobe has documentation as well.