Reputation: 1995
I want to fetch all the pages below the current path using query, as i need to sort them also so using the query. I am using below criteria which is giving me the pages below hierarchy but also goes deep till it contains child.
path=/content/geometrixx/en/toolbar
type=cq:Page
orderby=@jcr:content/cq:lastModified
I show be below result like :
/content/geometrixx/en/toolbar/newsletter (crxde, html, json)
/content/geometrixx/en/toolbar/sitemap (crxde, html, json)
/content/geometrixx/en/toolbar/account (crxde, html, json)
/content/geometrixx/en/toolbar/account/register (crxde, html, json)
/content/geometrixx/en/toolbar/account/register/thank_you (crxde, html, json)
As in Account page i dont need the sub pages in result set. Please provide any criteria that fit into such type of query.
Thanks
Upvotes: 2
Views: 3298
Reputation: 9281
You can use flat property of the PathPredicateEvaluator
The sample query would be
type=cq:Page
path=/content/geometrixx/en/toolbar
path.flat=true
orderby=@jcr:content/cq:lastModified
orderby.sort=desc
It would translate to the following XPath query
/jcr:root/content/geometrixx/en/toolbar/element(*, cq:Page)
order by jcr:content/@cq:lastModified descending
To know more about the various properties available, refer the implementing classes of PredicateEvaluator.
Upvotes: 2
Reputation: 6754
If you're using an XPath query, you can simply remove the double forward slash. E.g. using the QueryBuilder debugger, your predicates give an XPath of /jcr:root/content/geometrixx/en/toolbar//element(*, cq:Page)
If you change this to:
/jcr:root/content/geometrixx/en/toolbar/element(*, cq:Page)
i.e. removing the second forward slash immediately before "element", it will just search direct children. You can preview this on the CRX explorer:
http://localhost:4502/crx/explorer/ui/search.jsp?Path=&Query=%2fjcr%3aroot%2fcontent%2fgeometrixx%2fen%2ftoolbar%2felement(*%2c%20cq%3aPage)
Upvotes: 0