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

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

maheshbabuvoma
Level 2
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
Asutosh_Jena_
Correct answer by
Community Advisor
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
bilal_ahmad
Level 5
Level 5

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.

maheshbabuvoma
Level 2
Level 2
Query query = queryBuilder.createQuery(PredicateGroup.create(predicateMap), request.getResourceResolver().adaptTo(Session.class)); SearchResult result = query.getResult();
Asutosh_Jena_
Correct answer by
Community Advisor
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