dsmiley commented on a change in pull request #757:
URL: https://github.com/apache/solr/pull/757#discussion_r837682433



##########
File path: 
solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java
##########
@@ -431,14 +435,27 @@ protected Locale parseLocale(String language, String 
country, String variant) {
 
     @Override
     protected Predicate<String> getFieldMatcher(String field) {
-      // TODO define hl.queryFieldPattern as a more advanced alternative to 
hl.requireFieldMatch.
 
       // note that the UH at Lucene level default to effectively "true"
       if (params.getFieldBool(field, HighlightParams.FIELD_MATCH, false)) {
         return field::equals; // requireFieldMatch
-      } else {
-        return NOT_REQUIRED_FIELD_MATCH_PREDICATE;
       }
+
+      String[] queryFieldPattern =
+          params.getFieldParams(field, HighlightParams.QUERY_FIELD_PATTERN);
+      if (queryFieldPattern != null && queryFieldPattern.length != 0) {
+
+        Collection<String> indexedFields = 
solrIndexSearcher.getDocFetcher().getIndexedFieldNames();
+
+        final Set<String> fields =
+            Set.of(expandWildcardsInHighlightFields(indexedFields, 
queryFieldPattern));
+        if (fields.isEmpty()) {
+          return NO_FIELD_MATCH_PREDICATE;
+        }

Review comment:
       These lines are fine but I just want to point out that it isn't 
necessary and it's a dubious optimization.

##########
File path: solr/solr-ref-guide/modules/query-guide/pages/highlighting.adoc
##########
@@ -116,6 +116,17 @@ If set to `true`, only query terms aligning with the field 
being highlighted wil
 If the query references fields different from the field being highlighted and 
they have different text analysis, the query may not highlight query terms it 
should have and vice versa.
 The analysis used is that of the field being highlighted (`hl.fl`), not the 
query fields.
 
+`hl.queryFieldPattern`::
++
+[%autowidth,frame=none]
+|===
+|Optional |Default: `none`
+|===
++
+Similar to `hl.requireFieldMatch` but allows for multiple fields to match e.g. 
`q=fieldA:one OR fieldB:two OR fieldC:three` `hl.fl=fieldA` 
`hl.queryFieldPattern=fieldA,fieldB`

Review comment:
       Then please say so in the docs; that's what I was hinting at.  We could 
also conceivably throw a request error if both are specified, which would be 
nice but I leave it to you if you wish to.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to