Hi Ken,

The best way depends on your need.  If you still have the original text
around, it doesn't make sense to store the raw text in a Lucene index just
because you need highlighting.  In this case you can just store in a Lucene
field a reference to the original indexed text file and use this reference
to get the text for highlighting.

If you don't have access to the original text, then what you have done is
fine -- but you should consider using compressed field to store the text.
Lucene.Net supports compress field, but not out-of-the-box (because .NET 1.1
doesn't support ZIP compression.)  Look at the file SharpZipLibAdapter.cs to
see how you can use 3rd party compression, or use .NET 2.0 which has
compression support.

Regards,

-- George Aroush

-----Original Message-----
From: Ken Cox [mailto:[EMAIL PROTECTED] 
Sent: Friday, February 16, 2007 9:15 PM
To: [email protected]
Subject: Storing file Contents & using Highlighter in v2

Hi all,

I'm new to Lucene & have a quiestion about indexing the "contents" of files
& the use of the Highlighter.

I'm using Lucene 2.0.0.3 & Highlighter 2.0.0.1.

Based on the Test & Demo projects i've managed to get everything going just
fine except the ability to highlight the query string within a chunk of text
from the indexed contents.

The reason is the "contents" field doesn't actually store the text in the
index...

// Add the contents of the file to a field named "contents".  Specify a
Reader, // so that the text of the file is tokenized and indexed, but not
stored.
// Note that FileReader expects the file to be in the system's default
encoding.
// If that's not the case searching for special characters will fail.
doc.Add(new Field("contents", new System.IO.StreamReader(f.FullName,
System.Text.Encoding.Default)));

So my question is whats the best way to get the text of a file into the
index so i can use the Highlighter on it?

Currently i've added another field & am using a parser class i found in an
earlier version of Lucene to get the text of the files into the index.
Is this still the best way to do it using Lucene 2.0.0.3 or is there a new
way?

Thanks,
Ken

_________________________________________________________________
Discover fun and games at  @  http://xtramsn.co.nz/kids

Reply via email to