query builder + page filter | Community
Skip to main content
Level 4
October 16, 2015
Solved

query builder + page filter

  • October 16, 2015
  • 1 reply
  • 761 views

Hi,

I would like to do a search using query and then filter out all the pages which have an effective off time, I understand you need to use page filter but i am not how to use it in conjunction with jcr query.

Thanks

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by msulliva

You can you the PageManager to get a page from a path in a loop over your search hits:

PageManager pm = request.getResourceResolver().adaptTo(PageManager.class); SearchResult result = query.getResult(); for (Hit hit : result.getHits()) { Page page = pm.getContainingPage(hit.getPath()); Filter<Page> pageFilter = new PageFilter(); if (pageFilter.includes(page)) { // Matched... } }

1 reply

msullivaAccepted solution
Level 2
October 16, 2015

You can you the PageManager to get a page from a path in a loop over your search hits:

PageManager pm = request.getResourceResolver().adaptTo(PageManager.class); SearchResult result = query.getResult(); for (Hit hit : result.getHits()) { Page page = pm.getContainingPage(hit.getPath()); Filter<Page> pageFilter = new PageFilter(); if (pageFilter.includes(page)) { // Matched... } }