In Highlighter.Net, we can use NullFragmenter to return the entire field content. Is there any way we can do this in FastVectorHighlighter.Net?
Return Entire field from GetBestFragment in FastVectorHighlighter
732 Views Asked by Midhat At
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])
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 toGetBestFragment()), so why not just use it?