Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 70403 invoked from network); 11 Apr 2005 15:07:30 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 11 Apr 2005 15:07:30 -0000 Received: (qmail 66498 invoked by uid 500); 11 Apr 2005 15:07:07 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 66468 invoked by uid 500); 11 Apr 2005 15:07:07 -0000 Mailing-List: contact java-user-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-user@lucene.apache.org Delivered-To: mailing list java-user@lucene.apache.org Received: (qmail 66453 invoked by uid 99); 11 Apr 2005 15:07:06 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from mail.gan.no (HELO mail.gan.no) (195.159.151.132) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 11 Apr 2005 08:07:05 -0700 Received: from localhost (localhost [127.0.0.1]) by mail.gan.no (Postfix) with ESMTP id AB547F000B for ; Mon, 11 Apr 2005 17:07:02 +0200 (CEST) Received: from [172.16.16.192] (MetaMac.mediehuset.gan.no [172.16.16.192]) by mail.gan.no (Postfix) with ESMTP id BDEAEF000F for ; Mon, 11 Apr 2005 17:07:00 +0200 (CEST) Mime-Version: 1.0 (Apple Message framework v619.2) In-Reply-To: <72cf53b4050411064663c305d6@mail.gmail.com> References: <72cf53b405041102424ea6171e@mail.gmail.com> <72cf53b405041102507b598167@mail.gmail.com> <72cf53b4050411064663c305d6@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Message-Id: <2693f7c8c00ba33fc9dc11bc6eefa231@gan.no> Content-Transfer-Encoding: quoted-printable From: =?ISO-8859-1?Q?Karl_=D8ie?= Subject: Re: Lucene Search Result with Line Numbers? Date: Mon, 11 Apr 2005 17:07:01 +0200 To: java-user@lucene.apache.org X-Mailer: Apple Mail (2.619.2) X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at gan.no X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Oh, forgot your last question, thats why the field "line" has to be=20 stored, upon query you have to get the "line" number from the document=20= that represents the line and in "forward" / "back" actions you will=20 have sort the resultset by line value and print only chunks of that=20 result. Mvh Karl =D8ie > 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=3D 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 =D8ie 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 =3D "crash.java"; >> int line_number =3D 0; >> while(reader!=3DEOF) { >> String line =3D reader.readLine(); >> Document ld =3D 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=20= >> 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=20 >> highlighting >> bases its result on groups of occurencies of text, not line numbers. >> >> Mvh Karl =D8ie >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > - Real life should have a search function. I need my socks. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org