Return Entire field from GetBestFragment in FastVectorHighlighter

720 Views Asked by At

In Highlighter.Net, we can use NullFragmenter to return the entire field content. Is there any way we can do this in FastVectorHighlighter.Net?

3

There are 3 best solutions below

1
On

If you use SimpleFragListBuilder-fragmenter for FastVectorHighlighter then need to modify a public static properties of fragmenter to manage fragment size:

var fieldContent = "some data";

SimpleFragListBuilder.MARGIN = fieldContent.Length;
SimpleFragListBuilder.MIN_FRAG_CHAR_SIZE = SimpleFragListBuilder.MARGIN*3;

var result = highlighter.GetBestFragment(.., fragCharSize: SimpleFragListBuilder.MIN_FRAG_CHAR_SIZE);

(see source for details - 'Lucene.Net 3.0.3 SimpleFragListBuilder.cs' [http://lucenenet.apache.org/docs/3.0.3/dd/d38/_simple_frag_list_builder_8cs_source.html])

2
On

Isn't it an option to just use document.Get("field_name") and return the entire field content in such a way? You probably have you document somewhere in the context anyway (as you need doc id to GetBestFragment()), so why not just use it?

0
On

There is a patch for java FVH that claims to do this. I haven't personally tested it.

https://issues.apache.org/jira/browse/LUCENE-2464