Return-Path: Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: (qmail 30922 invoked from network); 24 Nov 2006 14:01:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Nov 2006 14:01:53 -0000 Received: (qmail 90502 invoked by uid 500); 24 Nov 2006 14:01:55 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 90293 invoked by uid 500); 24 Nov 2006 14:01:54 -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 90281 invoked by uid 99); 24 Nov 2006 14:01:54 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Nov 2006 06:01:54 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of erickerickson@gmail.com designates 64.233.182.187 as permitted sender) Received: from [64.233.182.187] (HELO nf-out-0910.google.com) (64.233.182.187) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Nov 2006 06:01:42 -0800 Received: by nf-out-0910.google.com with SMTP id n28so1120481nfc for ; Fri, 24 Nov 2006 06:01:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=iMBCg/6WjNtSYFiEmPVzbiZG/NVBcmJl6S+zfHo+fBqE/A6hh3QpP9GIPkdFlWu93eYmBlLs8NLoI4CvUT9vzYviIJ8rZt9AXtVI9eiRL40aFmMBtkPcczO5+PSXxxIdI1VxdRf34wO16PUXHXBf0VCAA/Kfn+sOuj9APDfEZZs= Received: by 10.82.175.2 with SMTP id x2mr1596900bue.1164376880098; Fri, 24 Nov 2006 06:01:20 -0800 (PST) Received: by 10.82.181.9 with HTTP; Fri, 24 Nov 2006 06:01:20 -0800 (PST) Message-ID: <359a92830611240601t2f9164das385be5dbaf9b3c11@mail.gmail.com> Date: Fri, 24 Nov 2006 09:01:20 -0500 From: "Erick Erickson" To: java-user@lucene.apache.org Subject: Re: Newbie Search Question In-Reply-To: <7513261.post@talk.nabble.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_59079_31944701.1164376880057" References: <7438630.post@talk.nabble.com> <29AA93ED-F339-49BB-8D37-E4DDF0D987A5@ehatchersolutions.com> <7506220.post@talk.nabble.com> <359a92830611230537j1307866coe4d7bc5a0e1902a3@mail.gmail.com> <7513261.post@talk.nabble.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_59079_31944701.1164376880057 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline If we're still dealing with StringReader(text) throwing an error.... It really shouldn't unless the document has no field named "contents". Here's what I'd do... Get a copy of Luke (google luke lucene) to examine your index. Figure out what the document ID is that you're blowing up on and look at it in Luke to be sure that there's text in the contents field. Watch case etc. You shouldn't be getting a null here unless 1> your doc ID is not in your index or 2> your document doesn't have such a field. And how are you storing your date? Field.Store.YES? NO? COMPRESSED? Best Erick On 11/23/06, sirakov wrote: > > > > Erick Erickson wrote: > > > > So why not assign a string to "text" and try it again? Or show us the > code > > where you expect the text variable to get a value..... > > > > Erick > > > > > > I`m sorry that was a miss from my side. > > I've tried to put the simple code into SearchFiles, between > > Hits hits = searcher.search(query); > > and > > String path = doc.get("path"); > > Here the code: > > Highlighter highlighter = new Highlighter(new QueryScorer(query)); > > > > if (repeat > 0) { // repeat & time as > benchmark > Date start = new Date(); > for (int i = 0; i < repeat; i++) { > hits = searcher.search(query); > } > Date end = new Date(); > System.out.println("Time: "+(end.getTime()-start.getTime())+"ms"); > } > > System.out.println(hits.length() + " total matching documents"); > > final int HITS_PER_PAGE = 10; > for (int start = 0; start < hits.length(); start += HITS_PER_PAGE) { > int end = Math.min(hits.length(), start + HITS_PER_PAGE); > for (int i = start; i < end; i++) { > > if (raw) { // output raw format > System.out.println("doc="+hits.id(i)+" score="+hits.score(i)); > continue; > } > > Document doc = hits.doc(i); > > String text = hits.doc(i).get(field); //String field = > "contents"; > TokenStream tokenStream = analyzer.tokenStream(field, new > StringReader(text)); > // Get 3 best fragments and seperate with a "..." > String result = highlighter.getBestFragments(tokenStream, text, > 3, > "..."); > > > String path = doc.get("path"); > if (path != null) { > System.out.println((i+1) + ". " + > path);System.out.println("\t"+result); > String title = doc.get("title"); > if (title != null) { > System.out.println(" Title: " + doc.get("title")); > } > } else { > System.out.println((i+1) + ". " + "No path for this > document"); > } > } > > The bolded text was added by me. I hope, i have made the changes in the > right file :) > -- > View this message in context: > http://www.nabble.com/Newbie-Search-Question-tf2667479.html#a7513261 > Sent from the Lucene - Java Users mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > > ------=_Part_59079_31944701.1164376880057--