You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Ryan Heinen <ry...@elasticpath.com> on 2006/09/28 23:55:41 UTC
NPE thrown in invertDocument
Hello,
I am creating an index using a RAMDirectory, and am running across a
situation where when I call IndexSearcher.addDocument it throws a
NullPointerException.
I'll provide the stack trace first, and then give you any details that
may help in resolving this problem.
Exception in thread "main" java.lang.NullPointerException
at
org.apache.lucene.index.DocumentWriter.invertDocument(DocumentWriter.java:162)
at
org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:93)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:476)
at org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:462)
Here is what is produced when I call toString() on the Document that I
created (only has one field because I commented out additions of fields
that seem to work):
Document<stored/uncompressed,indexed,tokenized<artist:Plastilina Mosh>>
Here is the basic gist of what I am doing:
I am looping through a bunch of items, and creating a document for each
language that I need to index each item in. The only difference (as far
as I can tell) between this document and one that works is that I am
extracting a localized value for the particular field that I am
building, in this case the Italian version of the text. Neither the
field name, nor the field value are null.
Here is some context from the Lucene source around where the exception
is being thrown (DocumentWriter.java):
Reader reader; // find or make Reader
if (field.readerValue() != null)
reader = field.readerValue();
else if (field.stringValue() != null)
reader = new StringReader(field.stringValue());
else
throw new IllegalArgumentException
("field must have either String or Reader value");
// Tokenize field and add to postingTable
TokenStream stream = analyzer.tokenStream(fieldName, reader);
//LINE 162, NPE THROWN HERE ^^^
So it stands to reason that either fieldName or reader is null. Why I
don't exactly know.
Has anyone else ran into this issue before? Could it have anything to do
with the encoding of the String that I am adding to the document?
Thanks in advance for any help,
Ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: [BULK] Re: NPE thrown in invertDocument
Posted by Ryan Heinen <ry...@elasticpath.com>.
Daniel Naber wrote:
> On Thursday 28 September 2006 23:55, Ryan Heinen wrote:
>
>> I am creating an index using a RAMDirectory, and am running across a
>> situation where when I call IndexSearcher.addDocument it throws a
>> NullPointerException.
>
> Could you create a small test case that reporduces this? This usually makes
> it easier to find the problem (for you) or to fix the bug (for the
> developers) if there is any.
I'll do what I can to isolate this to a simple test case. Thanks,
Ryan
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: [BULK] Re: NPE thrown in invertDocument [RESOLVED]
Posted by Ryan Heinen <ry...@elasticpath.com>.
Daniel Naber wrote:
> On Thursday 28 September 2006 23:55, Ryan Heinen wrote:
>
>> I am creating an index using a RAMDirectory, and am running across a
>> situation where when I call IndexSearcher.addDocument it throws a
>> NullPointerException.
>
> Could you create a small test case that reporduces this? This usually makes
> it easier to find the problem (for you) or to fix the bug (for the
> developers) if there is any.
Well, I finally had a chance to take a closer look at the code in an
attempt to create a test case when I discovered that the particular
IndexSearcher that I was having trouble with was being given null as
it's analyzer.
Sorry for the false alarm, and thanks for the help,
Ryan
>
> Regards
> Daniel
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: NPE thrown in invertDocument
Posted by Daniel Naber <lu...@danielnaber.de>.
On Thursday 28 September 2006 23:55, Ryan Heinen wrote:
> I am creating an index using a RAMDirectory, and am running across a
> situation where when I call IndexSearcher.addDocument it throws a
> NullPointerException.
Could you create a small test case that reporduces this? This usually makes
it easier to find the problem (for you) or to fix the bug (for the
developers) if there is any.
Regards
Daniel
--
http://www.danielnaber.de
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: NPE thrown in invertDocument
Posted by Ryan Heinen <ry...@elasticpath.com>.
I just thought I should add that I am using Lucene 2.0.0.
Thanks,
Ryan
Ryan Heinen wrote:
> Hello,
>
> I am creating an index using a RAMDirectory, and am running across a
> situation where when I call IndexSearcher.addDocument it throws a
> NullPointerException.
>
> I'll provide the stack trace first, and then give you any details that
> may help in resolving this problem.
>
> Exception in thread "main" java.lang.NullPointerException
> at
> org.apache.lucene.index.DocumentWriter.invertDocument(DocumentWriter.java:162)
>
> at
> org.apache.lucene.index.DocumentWriter.addDocument(DocumentWriter.java:93)
> at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:476)
> at
> org.apache.lucene.index.IndexWriter.addDocument(IndexWriter.java:462)
>
>
> Here is what is produced when I call toString() on the Document that I
> created (only has one field because I commented out additions of fields
> that seem to work):
>
> Document<stored/uncompressed,indexed,tokenized<artist:Plastilina Mosh>>
>
> Here is the basic gist of what I am doing:
>
> I am looping through a bunch of items, and creating a document for each
> language that I need to index each item in. The only difference (as far
> as I can tell) between this document and one that works is that I am
> extracting a localized value for the particular field that I am
> building, in this case the Italian version of the text. Neither the
> field name, nor the field value are null.
>
> Here is some context from the Lucene source around where the exception
> is being thrown (DocumentWriter.java):
>
> Reader reader; // find or make Reader
> if (field.readerValue() != null)
> reader = field.readerValue();
> else if (field.stringValue() != null)
> reader = new StringReader(field.stringValue());
> else
> throw new IllegalArgumentException
> ("field must have either String or Reader value");
>
> // Tokenize field and add to postingTable
> TokenStream stream = analyzer.tokenStream(fieldName, reader);
> //LINE 162, NPE THROWN HERE ^^^
>
> So it stands to reason that either fieldName or reader is null. Why I
> don't exactly know.
>
> Has anyone else ran into this issue before? Could it have anything to do
> with the encoding of the String that I am adding to the document?
>
> Thanks in advance for any help,
>
> Ryan
>
> ---------------------------------------------------------------------
> 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