apanimesh061 commented on a change in pull request #412:
URL: https://github.com/apache/lucene/pull/412#discussion_r737588612



##########
File path: 
lucene/highlighter/src/java/org/apache/lucene/search/uhighlight/UnifiedHighlighter.java
##########
@@ -143,6 +143,106 @@
 
   private int cacheFieldValCharsThreshold = DEFAULT_CACHE_CHARS_THRESHOLD;
 
+  /** Builder for UnifiedHighlighter. */
+  public abstract static class Builder<T extends Builder<T>> {
+    private IndexSearcher searcher;
+    private Analyzer indexAnalyzer;
+    private boolean handleMultiTermQuery = true;
+    private boolean highlightPhrasesStrictly = true;
+    private boolean passageRelevancyOverSpeed = true;
+    private int maxLength = DEFAULT_MAX_LENGTH;
+    private Supplier<BreakIterator> breakIterator =
+        () -> BreakIterator.getSentenceInstance(Locale.ROOT);
+    private Predicate<String> fieldMatcher;
+    private PassageScorer scorer = new PassageScorer();
+    private PassageFormatter formatter = new DefaultPassageFormatter();
+    private int maxNoHighlightPassages = -1;
+    private int cacheFieldValCharsThreshold = DEFAULT_CACHE_CHARS_THRESHOLD;
+
+    public T withSearcher(IndexSearcher value) {
+      this.searcher = value;
+      return self();
+    }
+
+    public T withIndexAnalyzer(Analyzer value) {
+      this.indexAnalyzer = value;
+      return self();
+    }
+
+    public T withHandleMultiTermQuery(boolean value) {
+      this.handleMultiTermQuery = value;
+      return self();
+    }
+
+    public T withHighlightPhrasesStrictly(boolean value) {
+      this.highlightPhrasesStrictly = value;
+      return self();
+    }
+
+    public T withPassageRelevancyOverSpeed(boolean value) {
+      this.passageRelevancyOverSpeed = value;
+      return self();
+    }
+
+    public T withMaxLength(int value) {
+      if (value < 0 || value == Integer.MAX_VALUE) {
+        // two reasons: no overflow problems in 
BreakIterator.preceding(offset+1),
+        // our sentinel in the offsets queue uses this value to terminate.
+        throw new IllegalArgumentException("maxLength must be < 
Integer.MAX_VALUE");
+      }
+      this.maxLength = value;
+      return self();
+    }
+
+    public T withBreakIterator(Supplier<BreakIterator> value) {
+      this.breakIterator = value;
+      return self();
+    }
+
+    public T withFieldMatcher(Predicate<String> value) {
+      this.fieldMatcher = value;
+      return self();
+    }
+
+    public T withScorer(PassageScorer value) {
+      this.scorer = value;
+      return self();
+    }
+
+    public T withFormatter(PassageFormatter value) {
+      this.formatter = value;
+      return self();
+    }
+
+    public T withMaxNoHighlightPassages(int value) {
+      this.maxNoHighlightPassages = value;
+      return self();
+    }
+
+    public T withCacheFieldValCharsThreshold(int value) {
+      this.cacheFieldValCharsThreshold = value;
+      return self();
+    }
+
+    protected abstract T self();
+
+    public UnifiedHighlighter build() {
+      return new UnifiedHighlighter(this);
+    }
+  }
+
+  // Why? 
https://web.archive.org/web/20150920054846/https://weblogs.java.net/node/642849

Review comment:
       @dsmiley Is there a way to run the checks again on the code? I see that 
1/3 checks failed. The failure was due to `socket hang up`. I wonder if 
retrying might work.




-- 
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...@lucene.apache.org

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



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

Reply via email to