Expand my Community achievements bar.

Implementing full text search

Avatar

Former Community Member

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