diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java index f5a2d8107a8..f1aba9d1219 100644 --- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java +++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java @@ -1126,6 +1126,14 @@ public class BKDWriter implements Closeable { byte[] maxSplitPackedValue = new byte[packedBytesLength]; System.arraycopy(maxPackedValue, 0, maxSplitPackedValue, 0, packedBytesLength); + // When we are on this dim, below, we clear the ordBitSet: + int dimToClear; + if (numDims - 1 == splitDim) { + dimToClear = numDims - 2; + } else { + dimToClear = numDims - 1; + } + for(int dim=0;dim 1) { - ordBitSet.clear(0, pointCount); - } - // Recurse on left tree: build(2*nodeID, leafNodeOffset, leftSlices, ordBitSet, out,