Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ when told to. The admin UI now tells it to. (Nazerke Seidan, David Smiley)
* SOLR-15213: Atomic updates: "add" now uses add-or-replace logic for child documents. They can
also themselves be atomic updates. (James Ashbourne, Endika Posadas via David Smiley)

* SOLR-10321: highlighting (hl.method=unified): When there are no highlights for a field, don't
return the field in the response at all. (David Smiley)

* SOLR-15890: Add a limit to the Admin SQL panel if one is not included in the stmt (Joel Bernstein)

* SOLR-15887: Remove <jmx/> from shipped solrconfig.xm. (Eric Pugh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
public class UnifiedSolrHighlighter extends SolrHighlighter implements PluginInfoInitialized {

protected static final String SNIPPET_SEPARATOR = "\u0000";
private static final String[] ZERO_LEN_STR_ARRAY = new String[0];

@Override
public void init(PluginInfo info) {
Expand Down Expand Up @@ -174,7 +173,6 @@ protected NamedList<Object> encodeSnippets(String[] keys, String[] fieldNames, M
String snippet = snippets.get(field)[i];
if (snippet == null) {
//TODO reuse logic of DefaultSolrHighlighter.alternateField
summary.add(field, ZERO_LEN_STR_ARRAY);
} else {
// we used a special snippet separator char and we can now split on it.
summary.add(field, snippet.split(SNIPPET_SEPARATOR));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,23 @@ public void testComplexPhraseQParser() {
"count(//lst[@name='highlighting']/lst[@name='102']/arr[@name='text']/*)=1");
}

// SOLR-10321
public void testDontReturnEmptyHighlights() throws Exception {
clearIndex();
// this doc has no value for field text2
assertU(adoc("text", "third document", "id", "103"));
assertU(commit());
// query on text & text2. Assert we only highlight text; text2 shouldn't be present at all
assertJQ(
req(
"q", "text:document OR text2:document",
"hl", "true",
"hl.fl", "text, text2",
"sort", "id asc",
"hl", "true"),
"highlighting=={\n"
+ " '103':{\n"
+ " 'text':['third <em>document</em>']}}}");
}

}