mirror of https://github.com/apache/lucene.git
LUCENE-4712: MemoryIndex throws NPE in #normValues(String) if field does not exist
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1437604 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
891fcf99da
commit
f13080dd64
|
@ -74,6 +74,9 @@ Bug Fixes
|
|||
* LUCENE-4705: Pass on FilterStrategy in FilteredQuery if the filtered query is
|
||||
rewritten. (Simon Willnauer)
|
||||
|
||||
* LUCENE-4712: MemoryIndex#normValues() throws NPE if field doesn't exist.
|
||||
(Simon Willnauer, Ricky Pritchett)
|
||||
|
||||
* LUCENE-4550: Shapes wider than 180 degrees would use too much accuracy for the
|
||||
PrefixTree based SpatialStrategy. For a pathological case of nearly 360
|
||||
degrees and barely any height, it would generate so many indexed terms
|
||||
|
|
|
@ -1138,7 +1138,8 @@ public class MemoryIndex {
|
|||
|
||||
@Override
|
||||
public DocValues normValues(String field) {
|
||||
if (fieldInfos.get(field).omitsNorms())
|
||||
FieldInfo fieldInfo = fieldInfos.get(field);
|
||||
if (fieldInfo == null || fieldInfo.omitsNorms())
|
||||
return null;
|
||||
DocValues norms = cachedNormValues;
|
||||
Similarity sim = getSimilarity();
|
||||
|
|
|
@ -381,6 +381,17 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
|
|||
assertTrue("posGap" + mockAnalyzer.getPositionIncrementGap("field") , mindex.search(query) > 0.0001);
|
||||
}
|
||||
|
||||
public void testNonExistingsField() throws IOException {
|
||||
MemoryIndex mindex = new MemoryIndex(random().nextBoolean(), random().nextInt(50) * 1024 * 1024);
|
||||
MockAnalyzer mockAnalyzer = new MockAnalyzer(random());
|
||||
mindex.addField("field", "the quick brown fox", mockAnalyzer);
|
||||
AtomicReader reader = (AtomicReader) mindex.createSearcher().getIndexReader();
|
||||
assertNull(reader.docValues("not-in-index"));
|
||||
assertNull(reader.normValues("not-in-index"));
|
||||
assertNull(reader.termDocsEnum(new Term("not-in-index", "foo")));
|
||||
assertNull(reader.termPositionsEnum(new Term("not-in-index", "foo")));
|
||||
assertNull(reader.terms("not-in-index"));
|
||||
}
|
||||
|
||||
public void testDuellMemIndex() throws IOException {
|
||||
LineFileDocs lineFileDocs = new LineFileDocs(random());
|
||||
|
|
Loading…
Reference in New Issue