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

SOLVED

query builder + page filter

Avatar

Level 4

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

1 Accepted Solution

Avatar

Correct answer by
Level 2

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... } }

View solution in original post

1 Reply

Avatar

Correct answer by
Level 2

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... } }