FAQ
I was using this snippet of code with an older version of Lucene. It's doing a simple search then highlighting and showing 500 characters of the hit. I may have left something out but you get the idea...


var highlighter = new Highlighter(new QueryScorer(query));
highlighter.SetTextFragmenter(new SimpleFragmenter(500));
string details = doc.Get("details");
var result = highlighter.GetBestFragments(analyzer, details, 1);

I've upgraded to version 2.9.2 and FastVectorHighlighter seems to be the way to go. How would that Highlighter code look like with FastVectorHighlighter? This code compiles, runs, and returns results:


var highlighter = new FastVectorHighlighter(true, true);
var result = highlighter.GetBestFragments(highlighter.GetFieldQuery(query), reader, docId, "details", 500 /* ??? */, 2 /* ??? */);

but I'm not sure how to specify I want ~250 words on either side of the hit(s). There seems to be a lot more characters to the right of the search result. Can someone explain what the "500" and "2" parameters mean? Also, how can I get it to give me ~250 _words_  and not ~250 _characters_ of context? The search result looks weird because the first word is always cut off or just outputs one or two characters.

I'm indexing with this:

document.Add(new Field("details", details, Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));

After reading "8.4 FastVectorHighlighter" from Lucene in Action 2nd Edition I'm inclined to just go back to using Highlighter...

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouplucene-net-user @
categorieslucene
postedJun 24, '11 at 3:05a
activeJun 24, '11 at 3:05a
posts1
users1
websitelucene.apache.org

1 user in discussion

Ron Grabowski: 1 post

People

Translate

site design / logo © 2022 Grokbase