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 3AB0FE1C4 for ; Thu, 10 Jan 2013 02:15:19 +0000 (UTC) Received: (qmail 32735 invoked by uid 500); 10 Jan 2013 02:15:16 -0000 Delivered-To: apmail-lucene-java-user-archive@lucene.apache.org Received: (qmail 32684 invoked by uid 500); 10 Jan 2013 02:15:16 -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 32675 invoked by uid 99); 10 Jan 2013 02:15:16 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2013 02:15:16 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.210.54] (HELO mail-da0-f54.google.com) (209.85.210.54) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 10 Jan 2013 02:15:08 +0000 Received: by mail-da0-f54.google.com with SMTP id n2so22489dad.41 for ; Wed, 09 Jan 2013 18:14:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:x-gm-message-state; bh=azxMe0V1Y1/1FTZ4bMKBSRaL6s1jWZBrJa5DhbXhciw=; b=oILd1HSrRCi+O86Cj3aO01dYac9veOnDOFyksXUSjhnUHEiI47bNer4zIpRxYej0Gv arNmEVb4AstrxfAVysL129x1gh5aIdr7m8mXAwHxvrAtalo1Hw2MW5st1rzXE/Gcn9sp sCqr+BxeAXwlLIhF/QM0H/mnHAnICUCT8L7KBB94SD6C66I9+raSZ9fVA8kOgKh5MXLI DwIdAw7t+oTVXH2d6LrgbSOkrsGKdeBS3QV1xsRV2aEufA6fmWgflVbQhPHvJndb5l6j ewqkO6tMy4Q4gfSG811TepAWzaEWuNWSzfwlXJzzJEqUzYiETQl+mlgNYnbXDD1Gcj9z dfAg== X-Received: by 10.68.253.42 with SMTP id zx10mr29385386pbc.56.1357784087371; Wed, 09 Jan 2013 18:14:47 -0800 (PST) Received: from [192.168.0.11] (cpe-98-145-203-109.socal.res.rr.com. [98.145.203.109]) by mx.google.com with ESMTPS id nm2sm55568pbc.43.2013.01.09.18.14.45 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jan 2013 18:14:46 -0800 (PST) Message-ID: <50EE2408.6050002@getrailo.org> Date: Wed, 09 Jan 2013 18:14:32 -0800 From: "Igal @ getRailo.org" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: java-user@lucene.apache.org Subject: Re: NPE when adding a Document to an IndexWriter References: <50EE1110.7010900@getrailo.org> In-Reply-To: Content-Type: multipart/mixed; boundary="------------070409060303050309080808" X-Gm-Message-State: ALoCoQk50/jYL7QCh0i+Ueq2+zLdqqsSNV1L6aJaCWbgP7pqFJpJn5++KO6roQQMIjl9hNxGF5kQ X-Virus-Checked: Checked by ClamAV on apache.org --------------070409060303050309080808 Content-Type: multipart/alternative; boundary="------------030406020505000104070406" --------------030406020505000104070406 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit thanks for your reply. please see attached. I tried to maintain the structure of the code that I need to use in the library I'm building. I think it should work for you as long as you remove the package declaration at the top. when I run the attached file I get the following output: debug: Exception in thread "main" java.lang.NullPointerException at org.apache.lucene.analysis.util.CharacterUtils$Java5CharacterUtils.fill(CharacterUtils.java:191) at org.apache.lucene.analysis.util.CharTokenizer.incrementToken(CharTokenizer.java:153) at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:102) at org.apache.lucene.index.DocFieldProcessor.processDocument(DocFieldProcessor.java:307) at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:244) at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:373) at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1445) at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1124) at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1105) at s21waf.text.lucene4.TestNPE.testIndexWriter(TestNPE.java:47) at s21waf.text.lucene4.TestNPE.main(TestNPE.java:111) Java Result: 1 BUILD SUCCESSFUL (total time: 0 seconds) thanks, Igal On 1/9/2013 5:23 PM, Chris Hostetter wrote: > : I keep getting an NPE when trying to add a Doc to an IndexWriter. I've > : minimized my code to very basic code. what am I doing wrong? pseudo-code: > > can you post a full test that other people can run to try and reproduce? > > it doesn't even have to be a junit test -- just some complete javacode > people paste into a main method and compile would be enough (right now we > have no idea what IndexWriterConfig you are using (could easily affect > things) or what directory you are using (less likeley, but still) > > > -Hoss > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org > For additional commands, e-mail: java-user-help@lucene.apache.org > --------------030406020505000104070406 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit thanks for your reply.  please see attached.  I tried to maintain the structure of the code that I need to use in the library I'm building.  I think it should work for you as long as you remove the package declaration at the top.

when I run the attached file I get the following output:

debug:
Exception in thread "main" java.lang.NullPointerException
    at org.apache.lucene.analysis.util.CharacterUtils$Java5CharacterUtils.fill(CharacterUtils.java:191)
    at org.apache.lucene.analysis.util.CharTokenizer.incrementToken(CharTokenizer.java:153)
    at org.apache.lucene.index.DocInverterPerField.processFields(DocInverterPerField.java:102)
    at org.apache.lucene.index.DocFieldProcessor.processDocument(DocFieldProcessor.java:307)
    at org.apache.lucene.index.DocumentsWriterPerThread.updateDocument(DocumentsWriterPerThread.java:244)
    at org.apache.lucene.index.DocumentsWriter.updateDocument(DocumentsWriter.java:373)
    at org.apache.lucene.index.IndexWriter.updateDocument(IndexWriter.java:1445)
    at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1124)
    at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:1105)
    at s21waf.text.lucene4.TestNPE.testIndexWriter(TestNPE.java:47)
    at s21waf.text.lucene4.TestNPE.main(TestNPE.java:111)
Java Result: 1
BUILD SUCCESSFUL (total time: 0 seconds)


thanks,

Igal


On 1/9/2013 5:23 PM, Chris Hostetter wrote:
: I keep getting an NPE when trying to add a Doc to an IndexWriter. I've
: minimized my code to very basic code.  what am I doing wrong? pseudo-code:

can you post a full test that other people can run to try and reproduce?  

it doesn't even have to be a junit test -- just some complete javacode 
people paste into a main method and compile would be enough (right now we 
have no idea what IndexWriterConfig you are using (could easily affect 
things) or what directory you are using (less likeley, but still)


-Hoss

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


--------------030406020505000104070406-- --------------070409060303050309080808 Content-Type: text/plain; charset=windows-1252; name="TestNPE.java" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="TestNPE.java" package s21waf.text.lucene4; import java.io.IOException; import java.io.Reader; import java.io.StringReader; import java.util.Collections; import java.util.List; import java.util.Map; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.WhitespaceTokenizer; import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.TextField; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; import org.apache.lucene.util.Version; public class TestNPE { public static void testIndexWriter() throws IOException { Directory dir = FSDirectory.open( new java.io.File( "F:/Test/Lucene/dir1" ) ); Document doc = new Document(); TextField ft; ft = new TextField( "desc1", "word1", Field.Store.YES ); doc.add( ft ); ft = new TextField( "desc2", "word2", Field.Store.YES ); doc.add( ft ); Analyzer analyzer = createAnalyzer( TokenizerConfig.DEFAULT ); IndexWriterConfig iwc = new IndexWriterConfig( Version.LUCENE_40, analyzer ); IndexWriter iw = new IndexWriter( dir, iwc); iw.addDocument(doc); iw.close(); } /** returns a WhitespaceTokenizerExt Tokenizer that strips html and replaces commas with comma-space */ public static Tokenizer getCharTokenizer( Reader input ) { // Tokenizer result = new WhitespaceTokenizer( Version.LUCENE_40, getCharFilter( input ) ); Tokenizer result = new WhitespaceTokenizer( Version.LUCENE_40, input ); // Tokenizer result = new StandardTokenizer( Version.LUCENE_40, input ); return result; } /** return getTokenizer( new StringReader( input ) ); */ public static Tokenizer getCharTokenizer( String input ) { return getCharTokenizer( new StringReader( input ) ); } public static Analyzer createAnalyzer( final TokenizerConfig config ) { Analyzer result = new Analyzer() { @Override protected Analyzer.TokenStreamComponents createComponents( String fieldName, Reader reader ) { Analyzer.TokenStreamComponents tsc = new Analyzer.TokenStreamComponents( getCharTokenizer( reader ) , getTokenFilterChain( reader, config ) ); return tsc; } }; return result; } public static TokenStream getTokenFilterChain( String input, TokenizerConfig config ) { return getTokenFilterChain( new StringReader( input ), config ); } public static TokenStream getTokenFilterChain( Reader input, TokenizerConfig config ) { TokenStream result = getCharTokenizer( input ); return result; } public static void main(String[] args) throws IOException { testIndexWriter(); } public static class TokenizerConfig { private int shingleSize = 3; private Map replaceList = Collections.EMPTY_MAP; private Map typeList = Collections.EMPTY_MAP; private List synonymList = Collections.EMPTY_LIST; public int getShingleSize() { return this.shingleSize; } public void setShingleSize( int value ) { this.shingleSize = value; } public void setReplaceList( Map replaceList ) { this.replaceList = replaceList; } public Map getReplaceList() { return this.replaceList; } public void setTypeList( Map typeList ) { this.typeList = typeList; } public Map getTypeList() { return this.typeList; } public void setSynonyms( List synonymList ) { this.synonymList = synonymList; } public List getSynonyms() { return synonymList; } public static final TokenizerConfig DEFAULT = new TokenizerConfig(); } } --------------070409060303050309080808 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org For additional commands, e-mail: java-user-help@lucene.apache.org --------------070409060303050309080808--