Lucene 3.6, java 1.6 I get the following:
java.lang.NullPointerException at
org.apache.lucene.index.DirectoryReader$MultiTermDocs.doc(DirectoryReader.ja
va:1179)
when running this code:
IndexReader reader = this.getReader(index);
int d = -1;
TermDocs td = reader.termDocs(this.createIdTerm(id));
if(td != null)
{
td.next();
d = td.doc();
}
private Term createIdTerm(String id)
{
return new Term(Constants.DEFAULT_ID_FIELD, id);
}
At the time this code runs I would expect that td would be null since there
are no documents in the index that match the term, but that is not the case.
Instead I get the NPE when trying td.doc(). I can wrap the code in a
try/catch for that line, but I think there must be a better way to determine
if I got any matches for a Term.
Edward W. Rouse
Comsquared System, Inc.
770-734-5301
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org