Minor tweak to getSnippets() method of PagedSearchController

This commit is contained in:
ryounes 2011-07-18 19:21:57 +00:00
parent e1c19ba56e
commit 1674c103a8
2 changed files with 6 additions and 5 deletions

View file

@ -445,8 +445,9 @@ public class PagedSearchController extends FreemarkerHttpServlet {
private String getSnippet(SolrDocument doc, QueryResponse response) {
String docId = doc.get(VitroSearchTermNames.DOCID).toString();
StringBuffer text = new StringBuffer("");
if (response.getHighlighting() != null && response.getHighlighting().get(docId) != null) {
List<String> snippets = response.getHighlighting().get(docId).get(VitroSearchTermNames.ALLTEXT);
Map<String, Map<String, List<String>>> highlights = response.getHighlighting();
if (highlights != null && highlights.get(docId) != null) {
List<String> snippets = highlights.get(docId).get(VitroSearchTermNames.ALLTEXT);
if (snippets != null && snippets.size() > 0) {
text.append("... " + snippets.get(0) + " ...");
}