Do you mean to show everything from the beginning of the field ? Last year I needed a highlighter which does return the whole field with all highlights , plus proper phrase highlighting which standard Java sandbox highlighter doesn't do afaik, let alone it is very slow , if you have long fields and want to generate 50-60 rows in html with highlighted fragments it takes ages. I ended up with contributions from Java world which you may use instead of standard highlighter though they require indexing with term vectors.
http://issues.apache.org/jira/browse/LUCENE-663 http://wiki.epc.ub.uu.se/display/~ronnie/Fast+Highlighter On Tue, Oct 7, 2008 at 3:51 PM, Ron Grabowski <[EMAIL PROTECTED]>wrote: > That's exactly what I was looking for! > > As a purely academic exercise do you have any pointers on how to make a > Fragmenter that displays text before the match? Can Lucene backtrack? I've > glanced at Token and saw that it had a StartOffset member. I can't think of > a use for such a Fragmenter...just curious. > > > > ----- Original Message ---- > From: Michael Mitiaguin <[EMAIL PROTECTED]> > To: lucene-net-user@incubator.apache.org > Sent: Monday, October 6, 2008 1:33:52 AM > Subject: Re: How to make Highlighter return more pre and post text of a > fragment? > > Ron, > > Have a look at > http://www.archivum.info/[EMAIL PROTECTED]/2008-01/msg00111.html > Probably you need to do similar changes if you want greater control of > fragments or at least instantiate Fragmenter with a parameter ( fragment > size) which should call a respective constructor. > > public class SimpleFragmenter : Fragmenter > > { > private const int DEFAULT_FRAGMENT_SIZE = 100; > private int currentNumFrags; > private int fragmentSize; > > > public SimpleFragmenter():this(DEFAULT_FRAGMENT_SIZE) > { > } > > > /// <summary> </summary> > /// <param name="fragmentSize">size in bytes of each fragment > /// </param> > public SimpleFragmenter(int fragmentSize) > { > this.fragmentSize = fragmentSize; > } > > > Regards > Michael > On Mon, Oct 6, 2008 at 4:40 PM, Ron Grabowski <[EMAIL PROTECTED] > >wrote: > > > Is there a way to configure Highlighter to return more pre and post text? > > For example suppose I'm searching text for "bank" from Alice in > Wonderland: > > > > her sister > > on the *bank*, and of having nothing > > > > I would like to get more post and pre text from my result: > > > > Alice was beginning to get very tired of sitting by her sister > > on the *bank*, and of having nothing to do: once or twice she had > > peeped into the book her sister was reading, but it had > > > > I've tried various calls to GetBestFragments: > > > > string[] highlightedFragments = highlighter.GetBestFragments(new > > StandardAnalyzer(), aliceInWonderland, 1); > > > > including bumping the 1 parameter to a larger number but the returned > array > > only has one item in it. I'm not looking for other matches in the text; I > > want to expand the best matched fragment to give the user more context > about > > the match. > > > > Thanks, > > Ron > > > > > >