SOLR-4877, LUCENE-5023: Removed SolrIndexSearcher#getDocSetNC()'s special case for handling TermQuery to prevent NullPointerException if reader does not have fields

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1487914 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2013-05-30 16:22:29 +00:00
parent 2c1af23df7
commit fecb6fb0a2
2 changed files with 6 additions and 31 deletions

View File

@ -212,6 +212,10 @@ Bug Fixes
* SOLR-4870: RecentUpdates.update() does not increment numUpdates loop counter
(Alexey Kudinov via shalin)
* SOLR-4877, LUCENE-5023: Removed SolrIndexSearcher#getDocSetNC()'s special
case for handling TermQuery to prevent NullPointerException if reader does
not have fields. (Bao Yang Yang, Uwe Schindler)
Other Changes
----------------------

View File

@ -1095,41 +1095,12 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable,SolrIn
DocSetCollector collector = new DocSetCollector(maxDoc()>>6, maxDoc());
if (filter==null) {
if (query instanceof TermQuery) {
Term t = ((TermQuery)query).getTerm();
for (final AtomicReaderContext leaf : leafContexts) {
final AtomicReader reader = leaf.reader();
collector.setNextReader(leaf);
Fields fields = reader.fields();
Terms terms = fields.terms(t.field());
BytesRef termBytes = t.bytes();
Bits liveDocs = reader.getLiveDocs();
DocsEnum docsEnum = null;
if (terms != null) {
final TermsEnum termsEnum = terms.iterator(null);
if (termsEnum.seekExact(termBytes, false)) {
docsEnum = termsEnum.docs(liveDocs, null, DocsEnum.FLAG_NONE);
}
}
if (docsEnum != null) {
int docid;
while ((docid = docsEnum.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
collector.collect(docid);
}
}
}
} else {
super.search(query,null,collector);
}
return collector.getDocSet();
super.search(query,null,collector);
} else {
Filter luceneFilter = filter.getTopFilter();
super.search(query, luceneFilter, collector);
return collector.getDocSet();
}
return collector.getDocSet();
}