apache / apache/lucene

UnifiedHighlighter: simplify "maxPassages" input API [LUCENE-7844]

Open
#8,895 7 comments 0 reactions 0 assignees View on GitHub
legacy-jira-fix-version:7.0 legacy-jira-priority:Minor module:highlighter type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

The "maxPassages" input to the UnifiedHighlighter can be provided as an array to some of the public methods on UnifiedHighlighter. When it's provided as an array, the index in the array is for the field in a parallel array. I think this is awkward and furthermore it's inconsistent with the way this highlighter customizes things on a by field basis. Instead, the parameter can be a simple int default (not an array), and then there can be a protected method like `getMaxPassageCount(String field` that returns an Integer which, when non-null, replaces the default value for this field.

Aside from API simplicity and consistency, this will also remove some annoying parallel array sorting going on.

---
Migrated from [LUCENE-7844](https://issues.apache.org/jira/browse/LUCENE-7844) by David Smiley (@dsmiley), updated May 30 2017
Attachments: [LUCENE_7844__UH_maxPassages_simplification.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-7844/LUCENE_7844__UH_maxPassages_simplification.patch)

Contributor guide

Open the contributing guide

Research direction

Start by inspecting UnifiedHighlighter's public methods that accept maxPassages and the existing by-field customization hooks. Review the attached LUCENE_7844__UH_maxPassages_simplification.patch for context. Done means the APIs use a simple integer default, field-specific overrides use a protected getMaxPassageCount(String field) hook, and the parallel-array sorting is removed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.