Expand my Community achievements bar.

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