1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
   | QueryResponse queryResponse = solr.query(query); SolrDocumentList results = queryResponse.getResults();   Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting(); for(SolrDocument solrDocument : results){                TXDocument document = new TXDocument();     document.setId(solrDocument.get("id").toString());                Map<String, List<String>> map = highlighting.get(solrDocument.get("id"));                if(map.get("path") != null){         document.setPath(map.get("path").toString());     } else {         document.setPath(solrDocument.get("path").toString());     }                String matchContents = "";     List<String> list = map.get("content");     if(list != null){         for(int i=0;i<list.size();i++){             if(i != 0){                 matchContents += " . . . ";             }             matchContents += list.get(i);         }     } else {         String docContent = solrDocument.get("content").toString();         matchContents = (docContent.length() > 75?docContent.substring(0, 75):docContent);     }     document.setContent(matchContents); }
   |