Developers,
I am encountering a null pointer exception when executing a wild card
query search on an empty index which doesn't contain any terms and of
course not the Term generated from the wild card query (ie the
WildCardTermEnum has an empty "actualEnum"). Please see below for what i
propose to be the fix (simple). I assume that this is sufficient or
would a change in one of the SegmentReader or TermsInfosReader classes
be more appropriate (not likely)?
I do not have access to commit this change, so if you deem that it is
necessary can you please make the modification.
Cheers,
Rasik Pandey
Basically in the constructor of WildCardTermEnum the constructor calls;
setEnum(reader.terms(new Term(searchTerm.field(), pre)));
----or
super.setEnum(an empty termEnum); or
FilteredTermEnum.setEnum(an empty termEnum);
Then in FilteredTermnEnum:
protected void setEnum(TermEnum actualEnum) throws IOException {
this.actualEnum = actualEnum;
// Find the first term that matches
!!!!!!!!the result of actualEnum.term(); is null in my
case!!!!!!!!!
Term term = actualEnum.term();
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!the below line leads to the null
pointer!!!!!!!!!!
if (termCompare(term))
!!!!!!!!!!!!!!!!!!!!see
below!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
currentTerm = term;
else next();
}
Then back in WildCardTermEnum:
final protected boolean termCompare(Term term) {
!!!!!!!!!!!the below line should test to ensure that "term" is not
null!!!!!!
if (field == term.field()) {
!!!!!!!!!!!!!!!!see below line for the simple
fix!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!below is the changed line for the simple
fix!!!!!!!!!!!!!!!!!!!!!!!!
if (term != null && field == term.field()) {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!
String searchText = term.text();
if (searchText.startsWith(pre)) {
return wildcardEquals(text, 0, searchText, preLen);
}
}
endEnum = true;
return false;
}
--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>
I am encountering a null pointer exception when executing a wild card
query search on an empty index which doesn't contain any terms and of
course not the Term generated from the wild card query (ie the
WildCardTermEnum has an empty "actualEnum"). Please see below for what i
propose to be the fix (simple). I assume that this is sufficient or
would a change in one of the SegmentReader or TermsInfosReader classes
be more appropriate (not likely)?
I do not have access to commit this change, so if you deem that it is
necessary can you please make the modification.
Cheers,
Rasik Pandey
Basically in the constructor of WildCardTermEnum the constructor calls;
setEnum(reader.terms(new Term(searchTerm.field(), pre)));
----or
super.setEnum(an empty termEnum); or
FilteredTermEnum.setEnum(an empty termEnum);
Then in FilteredTermnEnum:
protected void setEnum(TermEnum actualEnum) throws IOException {
this.actualEnum = actualEnum;
// Find the first term that matches
!!!!!!!!the result of actualEnum.term(); is null in my
case!!!!!!!!!
Term term = actualEnum.term();
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!the below line leads to the null
pointer!!!!!!!!!!
if (termCompare(term))
!!!!!!!!!!!!!!!!!!!!see
below!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
currentTerm = term;
else next();
}
Then back in WildCardTermEnum:
final protected boolean termCompare(Term term) {
!!!!!!!!!!!the below line should test to ensure that "term" is not
null!!!!!!
if (field == term.field()) {
!!!!!!!!!!!!!!!!see below line for the simple
fix!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!below is the changed line for the simple
fix!!!!!!!!!!!!!!!!!!!!!!!!
if (term != null && field == term.field()) {
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!
String searchText = term.text();
if (searchText.startsWith(pre)) {
return wildcardEquals(text, 0, searchText, preLen);
}
}
endEnum = true;
return false;
}
--
To unsubscribe, e-mail: <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>