apache / apache/lucene

FastVectorHighlighter loses boost values in phrase expansion and nested queries

Open
#15,442 6 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

FastVectorHighlighter incorrectly handles boost values in two scenarios:
1. **Phrase Expansion**: When overlapping phrases with different boosts expand, the expanded phrase loses original boost values and defaults to 1.0
2. **Nested Boosts**: Nested BoostQuery objects only preserve the outermost boost value, shouldn't we preserve max of them

## Impact
- Critical content gets weak highlighting despite high boost values
- Search result emphasis doesn't reflect query importance
- Breaks boost value semantics in search applications

## Example
**Scenario**: Legal document search where "contract termination" (boost: 10.0) and "termination clause" (boost: 5.0) should highlight "contract termination clause" prominently.

**Current Result**: "contract termination clause" gets boost 1.0 → weak highlighting
**Expected Result**: "contract termination clause" should get meaningful boost value → appropriate highlighting

### Version and environment details

- Lucene main branch
- Component: `lucene/highlighter` (FastVectorHighlighter)
- Likely affected code: `FieldQuery.java` phrase expansion logic

Contributor guide

Open the contributing guide

Research direction

Start with the phrase expansion logic in lucene/highlighter's FieldQuery.java and trace how FastVectorHighlighter handles overlapping phrases and nested BoostQuery objects. Reproduce the two described scenarios, then verify that expanded phrases retain meaningful original boosts and nested boosts preserve the maximum value.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
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.