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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]