OK thanks Andi. I'll switch to RC4.
I opened https://issues.apache.org/jira/browse/LUCENE-1564 for the
underlying Lucene bug.
Mike
Andi Vajda wrote:
On Fri, 13 Mar 2009, Andi Vajda wrote:
On Fri, 13 Mar 2009, Michael McCandless wrote:
* I'm attempting to re-use a field, by changing its value, and then
adding the document to an index:
lucene.initVM(lucene.CLASSPATH)
writer = lucene.IndexWriter(lucene.RAMDirectory(),
lucene.StandardAnalyzer())
doc = lucene.Document()
field = lucene.Field('field', '', lucene.Field.Store.NO,
lucene.Field.Index.NOT_ANALYZED)
field.setValue('abc')
doc.add(field)
writer.addDocument(doc)
writer.close()
However, unexpectedly I hit a Java NullPointerException in the
writer.addDocument. I hit a different exception if I use
lucene.Field.Index.ANALYZED instead. The corresponding code in
Lucene should work fine I think.
Two bugs at work here:
1. Because of the order in which the wrappers for setValue() were
generated and because JCC let's you pass a python string for a
Java
byte array (I should probably remove that since JArray('byte')
([...])
is the way to do this now), your setValue('abc') call gets
passed to
the Java Field.setValue(byte[]) overload.
I fixed this by indeed removing support for passing byte[] or char[]
via strings. Before the addition of JArray(), this was necessary but
could cause the problem you found where a byte[] or char[] overload
would be picked up before a String overload, as was the case here.
Your test case now works as originally written. The Java Lucene bug
we found is not hit anymore since the correct setValue() overload is
now invoked.
I uploaded a new release candidate, rc4, with this fix to the
staging are:
http://people.apache.org/~vajda/staging_area/
Andi..
2. Because of a probable Java Lucene bug, that fails to take and a
NullPointerException is thrown during indexing.
The following Java code illustrates the error:
import java.io.IOException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
public class t02 {
public static void main(String[] args)
throws IOException
{
IndexWriter writer = new IndexWriter(new RAMDirectory(),
new StandardAnalyzer());
Document doc = new Document();
Field field = new Field("field", "",
Field.Store.NO,
Field.Index.NOT_ANALYZED);
field.setValue(new byte[] { 'a', 'b', 'c' });
doc.add(field);
writer.addDocument(doc);
writer.close();
System.err.println("done");
}
}
Mike, what do you think ?
Andi..