From java-user-return-51352-apmail-lucene-java-user-archive=lucene.apache.org@lucene.apache.org Wed Nov 23 09:46:47 2011 Return-Path: X-Original-To: apmail-lucene-java-user-archive@www.apache.org Delivered-To: apmail-lucene-java-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BCA1D7183 for ; Wed, 23 Nov 2011 09:46:47 +0000 (UTC) Received: (qmail 10817 invoked by uid 500); 23 Nov 2011 09:46:45 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 10720 invoked by uid 500); 23 Nov 2011 09:46:45 -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 10710 invoked by uid 99); 23 Nov 2011 09:46:44 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 09:46:44 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ian.lea@gmail.com designates 209.85.213.176 as permitted sender) Received: from [209.85.213.176] (HELO mail-yx0-f176.google.com) (209.85.213.176) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Nov 2011 09:46:36 +0000 Received: by yenl9 with SMTP id l9so1221200yen.35 for ; Wed, 23 Nov 2011 01:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=zln7eBfDb7VoFgdDfZF1huVAh6v+n1rbvd0agukx1v8=; b=CITPFaxYHqNXEcZQakpJm8lifAhnjMohnQ0malcnPKazoFOSHNct5vKY2mGI0n3dVb IxPufj1vBhOgpSACTTHUHbZb9QcIe8XFkNKQU98UUYn2EodYOA2ssSL2KffHt9q3BYOT w/QmU61hMcyV6DwXlgAgmhQ4FQuZQPad5OLVE= Received: by 10.50.57.138 with SMTP id i10mr18592008igq.3.1322041575085; Wed, 23 Nov 2011 01:46:15 -0800 (PST) MIME-Version: 1.0 Received: by 10.231.171.72 with HTTP; Wed, 23 Nov 2011 01:45:54 -0800 (PST) In-Reply-To: <1321968903969-3527712.post@n3.nabble.com> References: <1321968903969-3527712.post@n3.nabble.com> From: Ian Lea Date: Wed, 23 Nov 2011 09:45:54 +0000 Message-ID: Subject: Re: highlighter by using term offsets To: java-user@lucene.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org I know nothing about highlighting or TermPositionVector, but first step on debugging NPEs on complex lines of code should be to break it down and find out exactly what is causing the exception. Is reader null? hits? Some other problem? -- Ian. On Tue, Nov 22, 2011 at 1:35 PM, starz10de wrote: > > =A0I'm writing a highlighter by using term offsets as follows: > > > IndexReader reader =3D IndexReader.open( indexPath ); > TermPositionVector tpv =3D (TermPositionVector)reader.getTermFreqVector( > hits[i].doc,"contents"); > > When I run the searcher, I face this error in > > =A0 =A0 =A0 =A0 =A0 =A0TermPositionVector tpv =3D > (TermPositionVector)reader.getTermFreqVector(hits[i].doc,"contents"); > > Exception in thread "main" java.lang.NullPointerException > =A0 =A0 =A0 =A0at servlet.SearchFiles.doPagingSearch(SearchFiles.java:274= ) > =A0 =A0 =A0 =A0at servlet.SearchFiles.SearchFiles(SearchFiles.java:159) > =A0 =A0 =A0 =A0at servlet.test.main(test.java:20) > > in the index , I stored the "contents" field as follows: > > doc.add( new Field( "contents", TextFilesContent, Field.Store.YES, > Field.Index.ANALYZED,Field.TermVector.WITH_OFFSETS ) ); > > > any hints? > > Thanks --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org