Phrase queries using SpanNearQuery highlight suspected bugs. [LUCENE-10609]
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
document: Blockchain technology 5G technology VR Technology AI Technology
analyzer: WhitespaceAnalyzer
query: spanNear([spanNear([title:Blockchain, title:technology], 0, true), spanNear([title:VR, title:Technology], 0, true)], 2, true)
```java
//query code
SpanQuery termQuery_sub01 = new SpanTermQuery(new Term("title", "Blockchain"));
SpanQuery termQuery_sub02 = new SpanTermQuery(new Term("title", "technology"));
SpanNearQuery spanNearQuery_Sub01 = new SpanNearQuery(new SpanQuery[] { termQuery_sub01, termQuery_sub02 }, 0, true);
SpanQuery termQuery_sub03 = new SpanTermQuery(new Term("title", "VR"));
SpanQuery termQuery_sub04 = new SpanTermQuery(new Term("title", "Technology"));
SpanNearQuery spanNearQuery_Sub02 = new SpanNearQuery(new SpanQuery[] { termQuery_sub03, termQuery_sub04 }, 0, true);
SpanNearQuery spanNearQuery = new SpanNearQuery(new SpanQuery[] { spanNearQuery_Sub01, spanNearQuery_Sub02 }, 2, true);
```
The query hits the document, but is there a problem with highlighting?
```java
//highlight code
QueryScorer scorer = new QueryScorer(query);
SimpleHTMLFormatter simpleHtmlFormatter = new SimpleHTMLFormatter("[", "]");
Highlighter highlighter = new Highlighter(simpleHtmlFormatter, scorer);
highlighter.setTextFragmenter(new SimpleFragmenter(100));
```
highlight result
[Blockchain] [technology] 5G [technology] [VR] [Technology] AI Technology
I think "Blockchain Technology" and "VR Technology" should be highlighted, but the "technology" in "5G Technology" should not be highlighted.
Uh, uh, UH, I'm not sure if it's a bug or if it's designed that way.
---
Migrated from [LUCENE-10609](https://issues.apache.org/jira/browse/LUCENE-10609) by FengFeng Cheng
Contributor guide
Assessment
This issue has not been assessed yet.