This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 476ab1e  SOLR-12901: UH: handle highlighting no fields Fixes 
CustomHighlightComponentTest.
476ab1e is described below

commit 476ab1e175147f5363c8d92c7aefb3400d28021b
Author: David Smiley <[email protected]>
AuthorDate: Sat Feb 5 01:02:01 2022 -0500

    SOLR-12901: UH: handle highlighting no fields
    Fixes CustomHighlightComponentTest.
---
 .../src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 
a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java 
b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
index 4466132..4c56200 100644
--- a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
+++ b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
@@ -18,6 +18,7 @@ package org.apache.solr.highlight;
 
 import java.io.IOException;
 import java.text.BreakIterator;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Locale;
@@ -145,7 +146,10 @@ public class UnifiedSolrHighlighter extends 
SolrHighlighter implements PluginInf
     }
 
     UnifiedHighlighter highlighter = getHighlighter(req);
-    Map<String, String[]> snippets = highlighter.highlightFields(fieldNames, 
query, docIDs, maxPassages);
+    Map<String, String[]> snippets =
+        fieldNames.length == 0
+            ? Collections.emptyMap()
+            : highlighter.highlightFields(fieldNames, query, docIDs, 
maxPassages);
     return encodeSnippets(keys, fieldNames, snippets);
   }
 

Reply via email to