String src_doc = "crash.java";
int line_number = 0;
while(reader!=EOF) {
String line = reader.readLine();
Document ld = new Document();
ld.add(new Field("id", src_doc, true, true, false));
ld.add(new Field("line", ""+line_number, true, true, false));
ld.add(new Field("text", line.toString(), false, true, true));
index_writer.addDocument(ld);
line_number++;
}This will create a small lucene document for each line, upon search you will find documents based on the content of the line and the line number as a field. The reason syntax highlighting works without creating a lucene document for each line is because syntax highlighting bases its result on groups of occurencies of text, not line numbers.
Mvh Karl �ie
On 11. apr. 2005, at 11.50, cerberus yao wrote:
- there is nothing wrong with using linux. if that's the lifestyle you want to live, i wont judge you. i just wont support you at the parades.Hi, Lucene users:
Does anyone knows how to add the Lucene search results with Line number in original source content? for example: I have a file "Test.java" which is indexed by lucene. When I search inside the index, how to enhance the search result with line number in Test.java?
ps. the lucene sandbox has a highlighter for search result. where can I find a line number decorator for search results?
Thx. Best regards,
-- Charley, Chang-Li Yao
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
