QueryResponse response1 = solr.query(query); response1.getHighlighting()
static <T> List<HighlightEntry<T>> convertAndAddHighlightQueryResponseToResultPage(@Nullable QueryResponse response, @Nullable SolrResultPage<T> page) { if (response == null || CollectionUtils.isEmpty(response.getHighlighting()) || page == null) { return Collections.emptyList(); } List<HighlightEntry<T>> mappedHighlights = new ArrayList<>(page.getSize()); Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); for (T item : page) { HighlightEntry<T> highlightEntry = processHighlightingForPageEntry(highlighting, item); mappedHighlights.add(highlightEntry); } page.setHighlighted(mappedHighlights); return mappedHighlights; }
@Override public Object getValueAt(int rowIndex, int columnIndex) { String columnName = getColumnName(columnIndex); if(response.getHighlighting() != null && response.getHighlighting().get(columnName) != null) { System.out.println(response.getHighlighting().get(columnName)); } return response.getResults().get(rowIndex).getFieldValue(columnName); }
if (m_queryResponse.getHighlighting() != null) { for (String key : m_queryResponse.getHighlighting().keySet()) { Map<String, ?> value = m_queryResponse.getHighlighting().get(key); Map<String, List<String>> innerResult = new HashMap<String, List<String>>(); for (String innerKey : value.keySet()) {
public List<Question> searchQuestion(String keyword, int offset, int count, String hlPre, String hlPos) throws IOException, SolrServerException { List<Question> questionList = new ArrayList<>(); SolrQuery query = new SolrQuery(keyword); query.setRows(count); query.setStart(offset); query.setHighlight(true); query.setHighlightSimplePre(hlPre); query.setHighlightSimplePost(hlPos); query.set("hl.fl", QUESTION_TITLE_FIELD + "," + QUESTION_CONTENT_FIELD); QueryResponse response = client.query(query); for (Map.Entry<String, Map<String, List<String>>> entry : response.getHighlighting().entrySet()) { Question q = new Question(); q.setId(Integer.parseInt(entry.getKey())); if (entry.getValue().containsKey(QUESTION_CONTENT_FIELD)) { List<String> contentList = entry.getValue().get(QUESTION_CONTENT_FIELD); if (contentList.size() > 0) { q.setContent(contentList.get(0)); } } if (entry.getValue().containsKey(QUESTION_TITLE_FIELD)) { List<String> titleList = entry.getValue().get(QUESTION_TITLE_FIELD); if (titleList.size() > 0) { q.setTitle(titleList.get(0)); } } questionList.add(q); } return questionList; }
String context = null; if (resp.getHighlighting() != null) { Map<String, List<String>> snippets = resp.getHighlighting() .get(entity.getId());
String context = null; if (resp.getHighlighting() != null) { Map<String, List<String>> snippets = resp.getHighlighting() .get(entity.getId());
if (searchTerm != null && response.getHighlighting().get(searchHit.getId()) != null) { List<String> fragments = response.getHighlighting().get(searchHit.getId()).get(this.content); if (fragments != null) { String[] bestFragments = new String[fragments.size() > 10 ? 10 : fragments.size()];
SolrDocumentList results = response.getResults(); if (!results.isEmpty() && response.getHighlighting().get(id) != null) { List<String> fragments = response.getHighlighting().get(id).get(this.content); String[] bestFragments = new String[fragments.size() > 100 ? 100 : fragments.size()]; for (int i = 0; i < bestFragments.length; i++)
static SearchResponse convertToSearchResponse(QueryResponse response) { return new BaseSearchResponse(response.getHighlighting(), convertToSearchFacetFieldMap(response.getFacetFields()), new SolrSearchResultDocumentList(response.getResults())); }
final Map<String,Map<String,List<String>>> highlighting = response.getHighlighting(); return Iterables.transform(results, new Function<SolrDocument,DocumentScore>()
Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting(); for (SolrDocument doc : docs) {
final Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); return Iterables.transform(results, new Function<SolrDocument, DocumentScore>() {
Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting(); for (SolrDocument doc : docs) {
if (solrQueryResponse.getHighlighting() != null) { Map<String, List<String>> highlightedFields = solrQueryResponse.getHighlighting().get( dso.getType() + "-" + dso.getID()); if (MapUtils.isNotEmpty(highlightedFields)) {
/** * Map solr query response to search results. * * @param queryResponse * the query response * @return the search results * */ public FulltextSearchResults mapSolrToSearchResults(final QueryResponse queryResponse) { if (queryResponse == null) { throw new GeneralServiceException("Null QueryResponse given."); } final SolrDocumentList responseDocumentList = queryResponse.getResults(); final Float maxScore = getMaxScoreToNormalize(responseDocumentList); if (LOG.isTraceEnabled()) { LOG.trace("Mapping response: {}", queryResponse); } final Map<String, Map<String, List<String>>> highlighting = queryResponse.getHighlighting(); final Iterator<SolrDocument> i = responseDocumentList.iterator(); // collect results final List<FulltextSearchResult> results = collectSearchResults(i, highlighting, maxScore); // create search results object String cursorMark = queryResponse.getNextCursorMark(); final FulltextSearchResults searchResults = new FulltextSearchResultsImpl(results, (int) responseDocumentList.getStart(), (int) responseDocumentList.getNumFound(), cursorMark); // add facet info searchResults.setFacetResult(FacetBuilder.mapFacetResult(queryResponse)); return searchResults; }
response.getHighlighting().forEach(highlights.consumer); } else if (highlights.results != null) { response.getHighlighting().forEach(new BiConsumer<String, Map<String, List<String>>>() { @Override public void accept(String id, Map<String, List<String>> highlightMap) {
Map<SolrField, List<String>> highlightsMap2 = new HashMap<>(); Map<String, Highlight> highlightsMap3 = new HashMap<>(); if (queryResponse.getHighlighting().get(id) != null) { for (Map.Entry<String, String> entry : solrFieldsToHightlightOnMap.entrySet()) { String field = entry.getKey(); String displayName = entry.getValue(); List<String> highlightSnippets = queryResponse.getHighlighting().get(id).get(field); if (highlightSnippets != null) { matchedFields.add(field);
final Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); return Iterables.transform(results, new Function<SolrDocument, DocumentScore>() {
final Map<String, Map<String, List<String>>> highlighting = response.getHighlighting(); return Iterables.transform(results, new Function<SolrDocument, DocumentScore>() {