@Test public void search_CHECK_HIGHLIGHTING() { JudgmentCriteria criteria = new JudgmentCriteria("świadków"); SearchResults<JudgmentSearchResult> results = judgmentSearchService.search(criteria, null); JudgmentSearchResult result = fetchAndAssertSingleSearchResult(results); assertEquals(41808, result.getId()); Pattern highlightPattern = Pattern.compile("<em>\\S+</em>"); Matcher highlightMatcher = highlightPattern.matcher(result.getContent()); List<String> highlights = Lists.newArrayList(); while (highlightMatcher.find()) { highlights.add(highlightMatcher.group()); } assertThat(highlights, contains("<em>świadków</em>", "<em>Świadkowie</em>", "<em>świadkowie</em>", "<em>świadek</em>")); assertEquals(3, StringUtils.countMatches(result.getContent(), " ... ")); }
@Override public SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria, Paging paging) { SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); QueryResponse response = null; try { response = solrServer.query(solrQuery); } catch (SolrServerException e) { e.printStackTrace(); return new SearchResults<JudgmentSearchResult>(); } SearchResults<JudgmentSearchResult> results = resultsTranslator.translate(response); return results; }
JudgmentSearchService implements SearchService<JudgmentSearchResult, JudgmentCriteria> { @Override public SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria, Paging paging) { SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); QueryResponse response = null; try { response = solrServer.query(solrQuery); } catch (SolrServerException e) { e.printStackTrace(); return new SearchResults<JudgmentSearchResult>(); } SearchResults<JudgmentSearchResult> results = resultsTranslator.translate(response); return results; } }
JudgmentSearchService implements SearchService<JudgmentSearchResult, JudgmentCriteria> { @Override public SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria, Paging paging) { SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); QueryResponse response = null; try { response = solrServer.query(solrQuery); } catch (SolrServerException e) { e.printStackTrace(); return new SearchResults<JudgmentSearchResult>(); } SearchResults<JudgmentSearchResult> results = resultsTranslator.translate(response); return results; }  }
JudgmentSearchService implements SearchService<JudgmentSearchResult, JudgmentCriteria> { @Override public SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria, Paging paging) { SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); QueryResponse response = null; try { response = solrServer.query(solrQuery); } catch (SolrServerException e) { e.printStackTrace(); return new SearchResults<JudgmentSearchResult>(); } SearchResults<JudgmentSearchResult> results = resultsTranslator.translate(response); return results; }  @Override SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria,
            Paging paging); }
JudgmentSearchService implements SearchService<JudgmentSearchResult, JudgmentCriteria> { @Override public SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria, Paging paging) { SolrQuery solrQuery = queryFactory.createQuery(criteria, paging); QueryResponse response = null; try { response = solrServer.query(solrQuery); } catch (SolrServerException e) { e.printStackTrace(); return new SearchResults<JudgmentSearchResult>(); } SearchResults<JudgmentSearchResult> results = resultsTranslator.translate(response); return results; }  @Override SearchResults<JudgmentSearchResult> search(JudgmentCriteria criteria,
            Paging paging);  }