Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Simple search, siblings only

adamm42245876
Level 2
Level 2

Would like to modify my simple search below to only search siblings, not children nodes.  Is this possible with Simple Search?

const search = resource.adaptTo(com.day.cq.search.SimpleSearch);

search.setSearchIn(currentPage.parent.getPath());

search.setHitsPerPage(3);

//exclude current page
const excludePathsPredicate = new com.day.cq.search.Predicate("excludepaths");

excludePathsPredicate.set("excludepaths", currentPage.getPath());

search.addPredicate(excludePathsPredicate);

//order

const orderPredicate = new com.day.cq.search.Predicate("orderby", com.day.cq.search.Predicate.ORDER_BY);

orderPredicate.set(com.day.cq.search.Predicate.ORDER_BY, '@' + com.day.cq.commons.jcr.JcrConstants.JCR_CREATED);

orderPredicate.set(com.day.cq.search.Predicate.PARAM_SORT, com.day.cq.search.Predicate.SORT_DESCENDING);

search.addPredicate(orderPredicate);

0 Replies