Oh, forgot your last question, thats why the field "line" has to be
stored, upon query you have to get the "line" number from the document
that represents the line and in "forward" / "back" actions you will
have sort the resultset by line value and print only chunks of that
result.
Mvh Karl Øie
Another question:
If we need to present the search result with the hit lines plus n
lines forward and backword, how can I do this if each lines are
seperated in each document?
for example:
1. contents in crash.java are:
public class crash {
public static void main(String[] args) {
}
}
2. query "main"
3. search result= the hit line +1 line and -1 line
1 public class crash {
2 public static void main(String[] args) {
3 }
On Apr 11, 2005 8:28 PM, Karl Øie <[EMAIL PROTECTED]> wrote:
Most indexing creates a Lucene document for each Source document. What
would need is to create a Lucene document for each line.
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
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
- Real life should have a search function. I need my socks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]