Buggy code:
final boolean writeTermFreq = ( currentFieldIndexOptions . compareTo ( DOCS_AND_FREQS ) ) >= 0 ; final boolean writePositions = ( currentFieldIndexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS ) ) >= 0 ; final boolean writeOffsets = ( currentFieldIndexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS ) ) >= 0 ; final boolean readTermFreq = ( indexOptions . compareTo ( DOCS_AND_FREQS ) ) >= 0 ; final boolean readPositions = ( indexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS ) ) >= 0 ; final boolean readOffsets = ( indexOptions . compareTo ( DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS ) ) >= 0 ; assert ( ! writeTermFreq ) || readTermFreq ; assert ( ! writePositions ) || readPositions ; assert ( ! writeOffsets ) || readOffsets ; assert ( ! writeOffsets ) || writePositions ; final Map < Term , Integer > segDeletes ; if ( ( ( state . segDeletes ) != null ) && ( ( state . segDeletes . terms . size ( ) ) > 0 ) ) { segDeletes = state . segDeletes . terms ; } else { segDeletes = null ; } final int [ ] termIDs = termsHashPerField . sortPostings ( termComp ) ; final int numTerms = termsHashPerField . bytesHash . size ( ) ; final BytesRef text = new BytesRef ( ) ; final FreqProxTermsWriterPerField . FreqProxPostingsArray postings = ( ( FreqProxTermsWriterPerField . FreqProxPostingsArray ) ( termsHashPerField . postingsArray ) ) ; final ByteSliceReader freq = new ByteSliceReader ( ) ; final ByteSliceReader prox = new ByteSliceReader ( ) ; FixedBitSet visitedDocs = new FixedBitSet ( state . numDocs ) ; long sumTotalTermFreq = 0 ; long sumDocFreq = 0 ; for ( int i = 0 ; i < numTerms ; i ++ ) { final int termID = termIDs [ i ] ; final int textStart = postings . textStarts [ termID ] ; termsHashPerField . bytePool . setBytesRef ( text , textStart ) ; termsHashPerField . initReader ( freq , termID , 0 ) ; if ( readPositions || readOffsets ) { termsHashPerField . initReader ( prox , termID , 1 ) ; } final PostingsConsumer postingsConsumer = termsConsumer . startTerm ( text ) ; final int delDocLimit ; if ( segDeletes != null ) { final Integer docIDUpto = segDeletes . get ( new Term ( fieldName , text ) ) ; if ( docIDUpto != null ) { delDocLimit = docIDUpto ; } else { delDocLimit = 0 ; } } else { delDocLimit = 0 ; } int numDocs = 0 ; long totTF = 0 ; int docID = 0 ; while ( true ) { final int termDocFreq ; if ( freq . eof ( ) ) { if ( ( postings . lastDocCodes [ termID ] ) != ( - 1 ) ) { docID = postings . lastDocIDs [ termID ] ; if ( readTermFreq ) { termDocFreq = postings . docFreqs [ termID ] ; } else { termDocFreq = 0 ; } postings . lastDocCodes [ termID ] = - 1 ; } else { break ; } } else { final int code = freq . readVInt ( ) ; if ( ! readTermFreq ) { docID += code ; termDocFreq = 0 ; } else { docID += code > > > 1 ; if ( ( code & 1 ) != 0 ) { termDocFreq = 1 ; } else { termDocFreq = freq . readVInt ( ) ; } } assert docID != ( postings . lastDocIDs [ termID ] ) ; } numDocs ++ ; assert docID < ( state . numDocs ) : ( ( "doc=" + docID ) + "<seq2seq4repair_space>maxDoc=" ) + ( state . numDocs ) ; visitedDocs . set ( docID ) ; postingsConsumer . startDoc ( docID , termDocFreq ) ; if ( docID < delDocLimit ) { if ( ( state . liveDocs ) == null ) { state . liveDocs = docState . docWriter . codec . liveDocsFormat ( ) . newLiveDocs ( state . numDocs ) ; } if ( state . liveDocs . get ( docID ) ) { ( state . delCountOnFlush ) ++ ; state . liveDocs . clear ( docID ) ; } } totTF += termDocFreq ; if ( readPositions || readOffsets ) { int position = 0 ; int offset = 0 ; for ( int j = 0 ; j < termDocFreq ; j ++ ) { final BytesRef thisPayload ; if ( readPositions ) { final int code = prox . readVInt ( ) ; <START_BUG> position += code > > 1 ; <END_BUG> if ( ( code & 1 ) != 0 ) { final int payloadLength = prox . readVInt ( ) ; if ( ( payload ) == null ) { payload = new BytesRef ( ) ; payload . bytes = new byte [ payloadLength ] ; } else if ( ( payload . bytes . length ) < payloadLength ) { payload . grow ( payloadLength ) ; } prox . readBytes ( payload . bytes , 0 , payloadLength ) ; payload . length = payloadLength ; thisPayload = payload ; } else { thisPayload = null ; } if ( readOffsets ) { final int startOffset = offset + ( prox . readVInt ( ) ) ; final int endOffset = startOffset + ( prox . readVInt ( ) ) ; offset = startOffset ; if ( writePositions ) { postingsConsumer . addPosition ( position , thisPayload , startOffset , endOffset ) ; } } else if ( writePositions ) { postingsConsumer . addPosition ( position , thisPayload , ( - 1 ) , ( - 1 ) ) ; } } } } postingsConsumer . finishDoc ( ) ; } termsConsumer . finishTerm ( text , new TermStats ( numDocs , totTF ) ) ; sumTotalTermFreq += totTF ; sumDocFreq += numDocs ; } termsConsumer . finish ( sumTotalTermFreq , sumDocFreq , visitedDocs . cardinality ( ) ) ; } }

Fix:
position += code > > > 1 ;