From 29de0f75e8d8c5e89a00c3b7a7fcfffad14065c9 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Tue, 6 Jun 2017 11:05:17 -0400 Subject: [PATCH] SOLR-10722: UH optimize for Solr's getFieldInfos --- solr/CHANGES.txt | 2 ++ .../org/apache/solr/highlight/UnifiedSolrHighlighter.java | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5343bc547f5..d7eb46f41ea 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -352,6 +352,8 @@ Optimizations so that the second phase which would normally involve calculating the domain for the bucket can be skipped entirely, leading to large performance improvements. (yonik) +* SOLR-10722: Speed up Solr's use of the UnifiedHighlighter be re-using FieldInfos. (David Smiley) + Other Changes ---------------------- 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 bd32fc1c16a..48cb874f499 100644 --- a/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java +++ b/solr/core/src/java/org/apache/solr/highlight/UnifiedSolrHighlighter.java @@ -26,6 +26,7 @@ import java.util.Set; import java.util.function.Predicate; import org.apache.lucene.document.Document; +import org.apache.lucene.index.FieldInfo; import org.apache.lucene.search.DocIdSetIterator; import org.apache.lucene.search.Query; import org.apache.lucene.search.uhighlight.CustomSeparatorBreakIterator; @@ -263,6 +264,12 @@ public class UnifiedSolrHighlighter extends SolrHighlighter implements PluginInf } } + // optimization for Solr which keeps a FieldInfos on-hand + @Override + protected FieldInfo getFieldInfo(String field) { + return ((SolrIndexSearcher)searcher).getFieldInfos().fieldInfo(field); + } + @Override public int getMaxNoHighlightPassages(String field) { boolean defaultSummary = params.getFieldBool(field, HighlightParams.DEFAULT_SUMMARY, false);