lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: java.lang.NullPointerExcpetion while indexing on linux
Date Tue, 19 Aug 2008 12:09:06 GMT

On quick look that code looks fine, though removeField is an expensive  
operation and unnecessary for this.

We really need the full traceback of the exception.

Mike

Aditi Goyal wrote:

> Thanks Michael and Ian for your valuable response.
> I am attaching a small default code. Please have a look and tell me  
> where am
> I going wrong.
>
> import lucene
> from lucene import Document, Field, initVM, CLASSPATH
>
> doc = Document()
> fieldA = Field('fieldA', "", Field.Store.YES,  
> Field.Index.UN_TOKENIZED)
> fieldB = Field('fieldB', "", Field.Store.YES, Field.Index.TOKENIZED)
> fieldC = Field ('fieldC', "", Field.Store.YES, Field.Index.TOKENIZED)
>
> doc.add(fieldA)
> doc.add(fieldB)
> doc.add(fieldC)
>
> def get_fields():
>    if doc.getField('FieldA') is not None:
>        doc.removeField('FieldA')
>    if doc.getField('FieldB') is not None:
>        doc.removeField('FieldB')
>    if doc.getField('FieldC') is not None:
>        doc.removeField('FieldC')
>
>    fieldA.setValue("abc")
>    doc.add(fieldA)
>    fieldB.setValue("xyz")
>    doc.add(fieldB)
>    fieldC.setValue("123")
>    doc.add(fieldC)
>
>    return doc
>
>
> def add_document():
>    doc = get_fields()
>    writer = lucene.IndexWriter(index_directory, analyzer, create_path)
>    writer.addDocument(doc)
>    writer.close()
>
> This writer.addDocument is throwing an exception saying
> java.lang.NullPointerException
>
> Thanks,
> Aditi
>
> On Tue, Aug 19, 2008 at 3:25 PM, Michael McCandless <
> lucene@mikemccandless.com> wrote:
>
>>
>> Ian Lea wrote:
>>
>> I don't think you need to remove the field and then add it again, but
>>> I've no idea if that is relevant to your problem or not.
>>>
>>
>> That's right: just leave the Field there and change its value  
>> (assuming the
>> doc you are changing to still uses that field).
>>
>> A full stack trace would be more help, and maybe an upgrade to 2.3.2,
>>> and maybe a snippet of your code, and what is JCC?
>>>
>>
>> JCC generates the necessary C/C++ glue code for Python to directly  
>> invoke
>> Java code.  The Chandler project created this for PyLucene because  
>> they were
>> having trouble with GCJ:
>>
>>   http://blog.chandlerproject.org/author/vajda/
>>
>> Mike
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>


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


Mime
View raw message