diff --git a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java index 55cdbf31e8d..e941911ef2b 100644 --- a/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java +++ b/lucene/core/src/java/org/apache/lucene/index/DefaultIndexingChain.java @@ -723,8 +723,10 @@ final class DefaultIndexingChain extends DocConsumer { if (invertState.position < invertState.lastPosition) { if (posIncr == 0) { throw new IllegalArgumentException("first position increment must be > 0 (got 0) for field '" + field.name() + "'"); + } else if (posIncr < 0) { + throw new IllegalArgumentException("position increment must be >= 0 (got " + posIncr + ") for field '" + field.name() + "'"); } else { - throw new IllegalArgumentException("position increments (and gaps) must be >= 0 (got " + posIncr + ") for field '" + field.name() + "'"); + throw new IllegalArgumentException("position overflowed Integer.MAX_VALUE (got posIncr=" + posIncr + " lastPosition=" + invertState.lastPosition + " position=" + invertState.position + ") for field '" + field.name() + "'"); } } else if (invertState.position > IndexWriter.MAX_POSITION) { throw new IllegalArgumentException("position " + invertState.position + " is too large for field '" + field.name() + "': max allowed position is " + IndexWriter.MAX_POSITION);