LUCENE-7083: default points merge logic should not ask a reader to merge points on a field that doesn't exist in that segment

This commit is contained in:
Mike McCandless 2016-03-08 13:28:28 -05:00
parent 9393a3190c
commit 2cac33a5ce
3 changed files with 27 additions and 0 deletions

View File

@ -54,6 +54,12 @@ public abstract class PointsWriter implements Closeable {
// This segment has no points // This segment has no points
continue; continue;
} }
FieldInfo readerFieldInfo = mergeState.fieldInfos[i].fieldInfo(fieldName);
if (readerFieldInfo == null) {
// This segment never saw this field
continue;
}
MergeState.DocMap docMap = mergeState.docMaps[i]; MergeState.DocMap docMap = mergeState.docMaps[i];
int docBase = mergeState.docBase[i]; int docBase = mergeState.docBase[i];
pointsReader.intersect(fieldInfo.name, pointsReader.intersect(fieldInfo.name,

View File

@ -4116,6 +4116,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
(mergeState.mergeFieldInfos.hasDocValues() ? "docValues" : "no docValues") + "; " + (mergeState.mergeFieldInfos.hasDocValues() ? "docValues" : "no docValues") + "; " +
(mergeState.mergeFieldInfos.hasProx() ? "prox" : "no prox") + "; " + (mergeState.mergeFieldInfos.hasProx() ? "prox" : "no prox") + "; " +
(mergeState.mergeFieldInfos.hasProx() ? "freqs" : "no freqs") + "; " + (mergeState.mergeFieldInfos.hasProx() ? "freqs" : "no freqs") + "; " +
(mergeState.mergeFieldInfos.hasPointValues() ? "points" : "no points") + "; " +
String.format(Locale.ROOT, String.format(Locale.ROOT,
"%.1f sec (%.1f sec stopped, %.1f sec paused) to merge segment [%.2f MB, %.2f MB/sec]", "%.1f sec (%.1f sec stopped, %.1f sec paused) to merge segment [%.2f MB, %.2f MB/sec]",
sec, sec,

View File

@ -39,6 +39,7 @@ import org.apache.lucene.index.PointValues.IntersectVisitor;
import org.apache.lucene.index.PointValues.Relation; import org.apache.lucene.index.PointValues.Relation;
import org.apache.lucene.index.PointValues; import org.apache.lucene.index.PointValues;
import org.apache.lucene.store.Directory; import org.apache.lucene.store.Directory;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
@ -562,4 +563,23 @@ public class TestPointValues extends LuceneTestCase {
r.close(); r.close();
dir.close(); dir.close();
} }
public void testPointsFieldMissingFromOneSegment() throws Exception {
Directory dir = FSDirectory.open(createTempDir());
IndexWriterConfig iwc = new IndexWriterConfig(null);
IndexWriter w = new IndexWriter(dir, iwc);
Document doc = new Document();
doc.add(new StringField("id", "0", Field.Store.NO));
doc.add(new IntPoint("int0", 0));
w.addDocument(doc);
w.commit();
doc = new Document();
doc.add(new IntPoint("int1", 17));
w.addDocument(doc);
w.forceMerge(1);
w.close();
dir.close();
}
} }