Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

SearchResult.getFacets() is null for query builder with map even after adding p.facets=true

Avatar

Level 2

I tried with query debug console and when I click on  Extract facets checkbox I was able to get response. But I need make call through java Query Builder API.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @maheshbabuvoma 

 

Try with the below code:

final PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
final Query query = queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
query.setExcerpt(Boolean.TRUE);
final SearchResult result = query.getResult();

 

Make sure to use resourceResolver with appropriate privilage, service user is preferred.

 

Thanks! 

View solution in original post

3 Replies

Avatar

Community Advisor

Hi @maheshbabuvoma can you please the piece of code(java) you're using to fetch the results ? I bet the issue is in your java code.

 

Thanks,

Bilal.

Avatar

Level 2
Query query = queryBuilder.createQuery(PredicateGroup.create(predicateMap), request.getResourceResolver().adaptTo(Session.class)); SearchResult result = query.getResult();

Avatar

Correct answer by
Community Advisor

Hi @maheshbabuvoma 

 

Try with the below code:

final PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
final Query query = queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
query.setExcerpt(Boolean.TRUE);
final SearchResult result = query.getResult();

 

Make sure to use resourceResolver with appropriate privilage, service user is preferred.

 

Thanks!