0 Replies Latest reply on Feb 14, 2018 8:08 AM by adamm42245876

    Simple search, siblings only

    adamm42245876

      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);