We have som issues sorting results from querybuilder.json (AEM 6.2). We want to be able to sort data on different properties, specified by the user (i.e. path, lastModified, title++).
Ordering data by "path" and "title" works fine:
querybuilder.json?path=%2Fcontent&type=cq%3APage&p.hits=selective&p.properties=jcr%3Apath%20jcr%3Atitle%20cq%3AlastModified&p.limit=-1&orderby=path&orderby.sort=asc
Ordering data by jcr:content properties does not work (list in random order), i.e. cq:lastModified:
querybuilder.json?path=%2Fcontent&type=cq%3APage&p.hits=selective&p.properties=jcr%3Apath%20jcr%3Atitle%20cq%3AlastModified&p.limit=-1&orderby=@jcr%3Acontent%2Fcq%3AlastModified&orderby.sort=asc
(Same as documented in QueryBuilder-api https://docs.adobe.com/docs/en/aem/6-2/develop/search/querybuilder-api.html#Sample Queries)
Trying different variations on specifying orderby doesnt help:
querybuilder.json?path=%2Fcontent%2Fsites%2Fsb1%2Fnb%2Fsmn%2Fprivat%2Fforsikring&type=cq%3APageContent&p.hits=selective&p.properties=jcr:title%20cq:lastModified&p.limit=10&orderby=jcr:content%2Fcq%3AlastModified&orderby.sort=asc (Without "@", fails)
querybuilder.json?path=%2Fcontent%2Fsites%2Fsb1%2Fnb%2Fsmn%2Fprivat%2Fforsikring&type=cq%3APageContent&p.hits=selective&p.properties=jcr:title%20cq:lastModified&p.limit=10&orderby=cq%3AlastModified&orderby.sort=asc (Without "@jcr:content", fails)
Same issue if we try to order by i.e cq:lastRolledout, jcr:created.
Anyone experienced same issue?
Best regards
Henrik Heiestad
Solved! Go to Solution.
Views
Replies
Total Likes
Dear Henrick,
Have looked again at your question,
Checked index in /oak:index/cqPageLucene/aggregates/cq:PageContent, it is exactly same as 6.1
According to CRX/DE shouldn't you be sorting on @cq:lastModified?
{
}
(tested on my AEM6.2 and it works via @cq:lastModifed, is it a viable option?)
Seems to be producing results here for correct orderby.
BTW, for up to date documentation look here[1]
[1] http://jackrabbit.apache.org/oak/docs/query/lucene.html
Regards,
Peter
Views
Replies
Total Likes
Hi
Please refer to this wonderful community article:
Link:- https://hashimkhan.in/2015/12/02/query-builder/
//Query Builder
In my case,
are working fine.
~kautuk
Views
Replies
Total Likes
Hi, thanks for your response, and for the link to the community article. It was very useful!
I have tested both your queries, and they work perfectly for me as well. But when I do some minor adjustments (querying for the content we look for):
http://localhost:4502/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby...
http://localhost:4502/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby...
Gives "unordered" results like:
{
"success":true,
"results":10,
"total":688,
"more":false,
"offset":0,
"hits":[
{
"path":"/content/sites/customer/bedrift/nettbank/jcr:content",
"lastModified":"2015-12-08 15:24:14",
"created":"2016-10-03 19:45:33"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/ansvar/styreansvarsforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:23",
"created":"2016-10-03 19:45:37"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/ansvar/ansvarsforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:23",
"created":"2016-10-03 19:45:37"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/ansvar/jcr:content",
"lastModified":"2015-12-08 15:24:22",
"created":"2016-10-03 19:45:37"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/ansvar/kriminalitetsforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:23",
"created":"2016-10-03 19:45:37"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/eiendom/prosjektforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:24",
"created":"2016-10-03 19:45:38"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/eiendom/boligbyggforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:24",
"created":"2016-10-03 19:45:38"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/eiendom/naringsbyggforsikring/jcr:content",
"lastModified":"2015-12-08 15:24:24",
"created":"2016-10-03 19:45:38"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/eiendom/jcr:content",
"lastModified":"2015-12-08 15:24:24",
"created":"2016-10-03 19:45:38"
},
{
"path":"/content/sites/customer/bedrift/produkter/forsikring/landbruk/jcr:content",
"lastModified":"2015-12-08 15:24:27",
"created":"2016-10-03 19:45:39"
}
]
}
Cant understand why it sorts differently my queries....(Seems like its just being sorted on path)
Best regards
Henrik Heiestad
Views
Replies
Total Likes
Dear Herick,
Thank you for asking this question,
Your query would start working, given you try to to remove the @jcr:content/, as whenever you are looking at PageContent you are already inside the jcr:content node itself.
KInd Regards,
Peter
Views
Replies
Total Likes
Hi,
thanks for your response. Tested the changes, but it gives same result (asc and desc both gives same result). Tested
/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby=@jcr:lastModified&orderby.sort=desc
/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby=@jcr:lastModified&orderby.sort=asc
/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby=jcr:lastModified&orderby.sort=desc
But typing nonexisting field, causes query to fail
/bin/querybuilder.json?path=/content/sites/customer&type=cq:PageContent&orderby=whatever&orderby.sort=desc
Querying for other types of content, seems to work, like nt:unstructured
/bin/querybuilder.json?path=/content/sitescustomer&type=nt:unstructured&orderby=@jcr:lastModified&orderby.sort=asc
Best regards
Henrik
Views
Replies
Total Likes
Dear Henrick,
Have looked again at your question,
Checked index in /oak:index/cqPageLucene/aggregates/cq:PageContent, it is exactly same as 6.1
According to CRX/DE shouldn't you be sorting on @cq:lastModified?
{
}
(tested on my AEM6.2 and it works via @cq:lastModifed, is it a viable option?)
Seems to be producing results here for correct orderby.
BTW, for up to date documentation look here[1]
[1] http://jackrabbit.apache.org/oak/docs/query/lucene.html
Regards,
Peter
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies