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
BedrockMission!

Learn more

View all

Sign in to view all badges

Implementing full text search

neethak90936115
Level 1
Level 1

Hi All,

I am implementing a full text search using the following  code
 

String searchTitle = ""; String searchTerm =request.getParameter("q"); String pageTitle, pagePath; Map<String, String> params = new HashMap<String, String>(); params.put("path", "/content/mysite"); params.put("type","cq:Page"); params.put("fulltext",searchTerm); params.put("orderby", "@jcr:score"); QueryBuilder builder=sling.getService(QueryBuilder.class); Session session = slingRequest.getResourceResolver().adaptTo(Session.class); Query query = builder.createQuery(PredicateGroup.create(params), session); SearchResult searchResult = query.getResult(); for (Hit hit : searchResult.getHits()) { String excerpt=hit.getExcerpt(); }

When i access the matched content from the hit using

hit.getExcerpt();

i am getting the first match (with145 character ).

Is there an way to get all the matched phrases from the content?

Thanks in advance

1 Reply