tags:

views:

510

answers:

2

in Lucene.Net,i am creating the document for searching a word and want to display before 10 words and after 10 words.i have used TermVector.

Lucene.Net.Documents.Field fldContent =
    new Lucene.Net.Documents.Field("content", content,
        Lucene.Net.Documents.Field.Store.YES,
        Lucene.Net.Documents.Field.Index.TOKENIZED,
        Lucene.Net.Documents.Field.TermVector.WITH_POSITIONS_OFFSETS);

Can anyone help me how to find out the keyword position and extract nearest 15 words. please send some code.

Thanks

Ashish

+1  A: 

Ashish, Check out the following link.

http://www.lucidimagination.com/blog/2009/07/18/the-spanquery/

Hitesh.

Indywizard
+1  A: 

You should be looking at Lucene highlighter, it extracts a snippet of text surrounding the query term. This link gives an example.

Mikos