Hi all,

I have been trying to generate some highlights using
`FastVectorHighlighter`:

```
String[] bestFragments = highlighter.getBestFragments(
    fieldQuery,
    leafReader,
    document,
    field,
    fragmentSize,
    maxNumFragments,
    new SimpleFragListBuilder(
        someMarginValue
    ),
    fragmentsBuilder,
    preTags,
    postTags,
    encoder
);
```
While it is more or less clear what other configuration parameters
influence, I have trouble figuring out the meaning behind the `margin`
passed into the `SimpleFragListBuilder` constructor.

I have found this ticket https://github.com/apache/lucene/issues/4587, in
which the constructor was added, but there's not much explanation on what
the value actually does. Looking into the implementation of
`BaseFragListBuilder#createFieldFragList(..)` and trying various
combinations of `margin` and `fragCharSize` values didn't lead me anywhere
as from what it seems, the fragment is "recentered" anyway:

```
final int newMargin = Math.max(0, (fragCharSize-matchLen)/2);
spanStart = currentPhraseStartOffset - newMargin;
if (spanStart < startOffset) {
    spanStart = startOffset;
}
```

Can someone point me to a resource where I can learn more about this
`margin` or provide some insights on what it stands for? That would be much
appreciated!

Have a nice day,
Marko

Reply via email to