The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

copernicus (1) [Avatar] Offline
#1
First, thanks a ton for the hard work on this book. I'm glad to now have the full second ed. A burning question I have as I'm pouring through trying to see if this is possible and covered in the book:

> Is it possible to get the surrounding text of a query hit? So if you are indexing a book by page, where each page represents an indexed Document, ultimately, you want to know how many times the query term occurs in the entire book and display a snippet of the surrounding text of those hits (going beyond just getting the Document that has 1+ hits in it). E.g. query:"scanner" had 17 hits in 13 Documents:
Hit 1 (in Doc 1): "... a top notch *scanner* is the Canon ..."
Hit 2 (also in Doc 1): "... with Xerox's 411 *scanner* your options ..."

Is this possible and/or covered in Lucene in Action?! I would be thrilled if the answer is yes. I know this probably would entail storing the text content in the field:
doc.Add(new Field(contentFieldName, content, Field.Store.YES, Field.Index.ANALYZED));

Thanks a million,
Copernicus
otis (156) [Avatar] Offline
#2
Re: Displaying hit context, is this covered in LIA?
Hi,

Have a look at the section about highlighting. See also http://search-lucene.com/?q=highlighter&fc_project=Lucene

Otis