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) { private String getSnippet(SolrDocument doc, QueryResponse response) {
String docId = doc.get(VitroSearchTermNames.DOCID).toString(); String docId = doc.get(VitroSearchTermNames.DOCID).toString();
StringBuffer text = new StringBuffer(""); StringBuffer text = new StringBuffer("");
if (response.getHighlighting() != null && response.getHighlighting().get(docId) != null) { Map<String, Map<String, List<String>>> highlights = response.getHighlighting();
List<String> snippets = response.getHighlighting().get(docId).get(VitroSearchTermNames.ALLTEXT); if (highlights != null && highlights.get(docId) != null) {
List<String> snippets = highlights.get(docId).get(VitroSearchTermNames.ALLTEXT);
if (snippets != null && snippets.size() > 0) { if (snippets != null && snippets.size() > 0) {
text.append("... " + snippets.get(0) + " ..."); text.append("... " + snippets.get(0) + " ...");
} }

View file

@ -158,9 +158,9 @@ public class IndividualToSolrDocument {
Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator(); Iterator<DataPropertyStatement> dataPropertyStmtIter = dataPropertyStatements.iterator();
while (dataPropertyStmtIter.hasNext()) { while (dataPropertyStmtIter.hasNext()) {
DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next(); DataPropertyStatement dataPropertyStmt = dataPropertyStmtIter.next();
if(dataPropertyStmt.getDatapropURI().equals(label)){ // we don't want label to be added to alltext if(dataPropertyStmt.getDatapropURI().equals(label)){ // we don't want label to be added to alltext
continue; continue;
} }
allTextValue.append(" "); allTextValue.append(" ");
allTextValue.append(((t=dataPropertyStmt.getData()) == null)?"":t); allTextValue.append(((t=dataPropertyStmt.getData()) == null)?"":t);
} }