0
votes

I am attempting to use AEM's querybuilder API to do a generic search. The problem I am currently having is creating pagination with the querybuilder. While using the ResultPage class in AEM with SearchResult to getNextPage(). I am getting the result com.day.cq.search.impl.result.ResultPageImpl@541bd4bf. How would I convert this into a URL? I already am using the offset and result total with the querybuilder but cannot find any more documentation to put me in the right direction.

  queryBuilder=resource.getResourceResolver().adaptTo(QueryBuilder.class);
//creating query based on the Query Description
Query query=queryBuilder.createQuery(PredicateGroup.create(map),session);
 //Getting and storing the Results
 List Pages1 = searchRes.getResultPages();
ResultPage nextpage = searchRes.getNextPage();
ResultPage lastpage = searchRes.getPreviousPage();
for (Hit hit:searchRes.getHits()){

String path1=hit.getPath();
String title1=hit.getTitle();
String excerpt1=hit.getExcerpt();
1

1 Answers

1
votes

You can't. The ResultPage objects have information about your search results that you got from the QueryBuilder. You can use the information to build your own pagination and search result page(s). As the SearchResult object contains only the results from the current page, you can use the ResultPage to easily get index and start of all the other pages that you could request from the QueryBuilder, based on the settings you used for your query, for example:

query.setStart(start);
query.setHitsPerPage(hitsPerPage);

But there is no connection to the frontend...