/** * The highlighted fragments. {@code null} if failed to highlight (for example, the field is not stored). */ public Text[] getFragments() { return fragments(); }
public String getSnippet(Map<String, HighlightField> highlights, YaCyQuery yq) { if (yq.yacyModifiers.contains("ranking")) { StringBuilder info = new StringBuilder(); for (String t: yq.positiveBag) { info.append(t).append('(').append(analyseToken(t, yq).trim()).append(')').append(' '); } for (String t: yq.negativeBag) { info.append('-').append(t).append('(').append(analyseToken(t, yq).trim()).append(')').append(' '); } return info.toString(); } List<String> description = super.getStrings(WebMapping.description_txt); String snippetDescription = description == null || description.isEmpty() ? "" : description.iterator().next().toString(); String snippetHighlight = highlights == null || highlights.isEmpty() ? "" : highlights.values().iterator().next().fragments()[0].toString(); String snippet = snippetDescription.length() > snippetHighlight.length() ? snippetDescription : snippetHighlight; return snippet; }
/** * The highlighted fragments. <tt>null</tt> if failed to highlight (for example, the field is not stored). */ public Text[] getFragments() { return fragments(); }
/** * The highlighted fragments. {@code null} if failed to highlight (for example, the field is not stored). */ public Text[] getFragments() { return fragments(); }
/** * The highlighted fragments. {@code null} if failed to highlight (for example, the field is not stored). */ public Text[] getFragments() { return fragments(); }
new HighlightField(fieldName, highlightField.fragments()));
private static void assertHighlight(SearchHit hit, String field, int fragment, Matcher<Integer> fragmentsMatcher, Matcher<String> matcher) { assertThat(hit.getHighlightFields(), hasKey(field)); assertThat(hit.getHighlightFields().get(field).fragments().length, fragmentsMatcher); assertThat(hit.getHighlightFields().get(field).fragments()[fragment].string(), matcher); }
hlFieldName = percolateQuery.getName() + "_" + entry.getKey(); hit.getHighlightFields().put(hlFieldName, new HighlightField(hlFieldName, entry.getValue().fragments())); } else { hlFieldName = percolateQuery.getName() + "_" + slot + "_" + entry.getKey(); hit.getHighlightFields().put(hlFieldName, new HighlightField(hlFieldName, entry.getValue().fragments()));
hlFieldName = percolateQuery.getName() + "_" + entry.getKey(); hit.getHighlightFields().put(hlFieldName, new HighlightField(hlFieldName, entry.getValue().fragments())); } else { hlFieldName = percolateQuery.getName() + "_" + slot + "_" + entry.getKey(); hit.getHighlightFields().put(hlFieldName, new HighlightField(hlFieldName, entry.getValue().fragments()));
new HighlightField(fieldName, highlightField.fragments()));
new HighlightField(fieldName, highlightField.fragments()));