SearchResult in json
Hi,
I'm using the Querybuilder api to query CQ within a Sling servlet. I want to know if there is a way to get the SearchResult in json directly?
Below is the code I'm doing in the servlet -
@SuppressWarnings("deprecation")
ResourceResolver resourceResolver = resolverFactory
.getAdministrativeResourceResolver(null);
session = resourceResolver.adaptTo(Session.class);
// String fulltextSearchTerm = "Geometrixx";
// create query description as hash map (simplest way, same as form
// post)
Map<String, String> map = new HashMap<String, String>();
// create query description as hash map (simplest way, same as form
// post)
// map.put("path", "/content");
map.put("type", "dam:Asset");
// can be done in map or with Query methods
map.put("p.hits", "full");
map.put("p.offset", "0"); // same as query.setStart(0) below
map.put("p.limit", "10"); // same as query.setHitsPerPage(20) below
map.put("p.nodedepth", "2");
Query query = builder.createQuery(PredicateGroup.create(map),
session);
// query.setStart(0);
// query.setHitsPerPage(20);
SearchResult result = query.getResult();
Thank you,
Koshy