Merged 5.2.N (5.2.1) to HEAD (5.2)

131295 gjames: SEARCH-195: Adding highlighting to the public api


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@132239 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2016-11-03 13:47:53 +00:00
parent 36b5206d45
commit 03acdaef03
4 changed files with 83 additions and 3 deletions

View File

@@ -33,11 +33,13 @@ import org.alfresco.rest.api.model.UserInfo;
import org.alfresco.rest.api.search.context.FacetFieldContext;
import org.alfresco.rest.api.search.context.FacetFieldContext.Bucket;
import org.alfresco.rest.api.search.context.SpellCheckContext;
import org.alfresco.rest.api.search.model.HighlightEntry;
import org.alfresco.rest.api.search.model.SearchEntry;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.api.search.context.SearchContext;
import org.alfresco.rest.api.search.context.FacetQueryContext;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SpellCheckResult;
import org.alfresco.util.Pair;
@@ -80,6 +82,7 @@ public class ResultMapper
Integer total = null;
List<Node> noderesults = new ArrayList();
Map<String, UserInfo> mapUserInfo = new HashMap<>(10);
Map<NodeRef, List<Pair<String, List<String>>>> hightLighting = results.getHighlighting();
results.forEach(row ->
{
@@ -87,7 +90,18 @@ public class ResultMapper
if (aNode != null)
{
float f = row.getScore();
aNode.setSearch(new SearchEntry(f));
List<HighlightEntry> highlightEntries = null;
List<Pair<String, List<String>>> high = hightLighting.get(row.getNodeRef());
if (high != null && !high.isEmpty())
{
highlightEntries = new ArrayList<HighlightEntry>(high.size());
for (Pair<String, List<String>> highlight:high)
{
highlightEntries.add(new HighlightEntry(highlight.getFirst(), highlight.getSecond()));
}
}
aNode.setSearch(new SearchEntry(f, highlightEntries));
noderesults.add(aNode);
}
else