hidingmyname opened a new issue, #16822:
URL: https://github.com/apache/lucene/issues/16822
### Description
**Location** (lucene @ main f94888d85c1):
`lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/package-info.java:165`
**Current text**
```
new SubInfo( phraseInfo.getText(), phraseInfo.getTermsOffsets(),
phraseInfo.getSeqnum() )
```
**Problem**: `SubInfo` takes 4 arguments (text, termsOffsets, seqnum, boost).
**Suggested fix**: Add `phraseInfo.getBoost()` as the 4th argument.
```diff
---
a/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/package-info.java
+++
b/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/package-info.java
@@ -163,5 +163,5 @@
* List<SubInfo> subInfos = new ArrayList<SubInfo>();
* for( WeightedPhraseInfo phraseInfo : phraseInfoList ){
- * subInfos.add( new SubInfo( phraseInfo.getText(),
phraseInfo.getTermsOffsets(), phraseInfo.getSeqnum() ) );
+ * subInfos.add( new SubInfo( phraseInfo.getText(),
phraseInfo.getTermsOffsets(), phraseInfo.getSeqnum(), phraseInfo.getBoost() ) );
* totalBoost += phraseInfo.getBoost();
* }
```
**Already fixed in Lucene.NET**: apache/lucenenet@2e320ea9c
**How Lucene.NET fixed it**: commit `2e320ea9cd1` (2021-03-30) "docs:
Lucene.Net.Highlighter: Fixed broken formatting and links (see #284, #300)",
file `src/Lucene.Net.Highlighter/VectorHighlight/package.md`
```diff
@@ -136,25 +137,32 @@ In Step 4, Fast Vector Highlighter creates
`FieldFragList` by reference to `Fiel
+---------------------------------+
The calculation for each `FieldFragList.WeightedFragInfo.totalBoost`
(weight)
-depends on the implementation of `FieldFragList.add( ... )`:
-
- public void add( int startOffset, int endOffset,
List<WeightedPhraseInfo> phraseInfoList ) {
- float totalBoost = 0;
- List<SubInfo> subInfos = new ArrayList<SubInfo>();
- for( WeightedPhraseInfo phraseInfo : phraseInfoList ){
- subInfos.add( new SubInfo( phraseInfo.getText(),
phraseInfo.getTermsOffsets(), phraseInfo.getSeqnum() ) );
- totalBoost += phraseInfo.getBoost();
- }
- getFragInfos().add( new WeightedFragInfo( startOffset, endOffset,
subInfos, totalBoost ) );
- }
+depends on the implementation of `FieldFragList.Add( ... )`:
+
+```cs
+public override void Add(int startOffset, int endOffset,
IList<WeightedPhraseInfo> phraseInfoList)
+{
+ float totalBoost = 0;
+ List<SubInfo> subInfos = new List<SubInfo>();
+ foreach (WeightedPhraseInfo phraseInfo in phraseInfoList)
+ {
+ subInfos.Add(new SubInfo(phraseInfo.GetText(),
phraseInfo.TermsOffsets, phraseInfo.Seqnum, phraseInfo.Boost));
+ totalBoost += phraseInfo.Boost;
+ }
+ FragInfos.Add(new WeightedFragInfo(startOffset, endOffset, subInfos,
totalBoost));
+}
+```
The used implementation of `FieldFragList` is noted in
`BaseFragListBuilder.createFieldFragList( ... )`:
- public FieldFragList createFieldFragList( FieldPhraseList
fieldPhraseList, int fragCharSize ){
- return createFieldFragList( fieldPhraseList, new
SimpleFieldFragList( fragCharSize ), fragCharSize );
- }
+```cs
+public override FieldFragList CreateFieldFragList(FieldPhraseList
fieldPhraseList, int fragCharSize)
+{
+ return CreateFieldFragList(fieldPhraseList, new
SimpleFieldFragList(fragCharSize), fragCharSize);
+}
+```
- Currently there are basically to approaches available:
+Currently there are basically to approaches available:
* `SimpleFragListBuilder using SimpleFieldFragList`:
_sum-of-boosts_-approach. The totalBoost is calculated by summarizing the
query-boosts per term. Per default a term is boosted by 1.0
```
I can submit a PR for this.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]