Buggy code:
} public ExtendedDismaxQParser ( String qstr , SolrParams localParams , SolrParams params , SolrQueryRequest req ) { } private Map < String , Float > queryFields ; private ExtendedDismaxQParser . UserFields userFields ; private Query parsedUserQuery ; private String [ ] boostParams ; private String [ ] multBoosts ; private List < Query > boostQueries ; private Query altUserQuery ; private QParser altQParser ; private SolrParams solrParams ; @ Override public Query parse ( ) throws ParseException { SolrParams localParams = getLocalParams ( ) ; SolrParams params = getParams ( ) ; solrParams = SolrParams . wrapDefaults ( localParams , params ) ; final String minShouldMatch = DisMaxQParser . parseMinShouldMatch ( req . getSchema ( ) , solrParams ) ; userFields = new ExtendedDismaxQParser . UserFields ( ExtendedDismaxQParser . U . parseFieldBoosts ( solrParams . getParams ( ExtendedDismaxQParser . DMP . UF ) ) ) ; queryFields = DisMaxQParser . parseQueryFields ( req . getSchema ( ) , solrParams ) ; List < FieldParams > phraseFields = ExtendedDismaxQParser . U . parseFieldBoostsAndSlop ( solrParams . getParams ( PF ) , 0 ) ; List < FieldParams > phraseFields2 = ExtendedDismaxQParser . U . parseFieldBoostsAndSlop ( solrParams . getParams ( "pf2" ) , 2 ) ; List < FieldParams > phraseFields3 = ExtendedDismaxQParser . U . parseFieldBoostsAndSlop ( solrParams . getParams ( "pf3" ) , 3 ) ; float tiebreaker = solrParams . getFloat ( TIE , 0.0F ) ; int pslop = solrParams . getInt ( PS , 0 ) ; int qslop = solrParams . getInt ( QS , 0 ) ; boolean stopwords = solrParams . getBool ( "stopwords" , true ) ; BooleanQuery query = new BooleanQuery ( true ) ; parsedUserQuery = null ; String userQuery = getString ( ) ; altUserQuery = null ; if ( ( userQuery == null ) || ( ( userQuery . trim ( ) . length ( ) ) == 0 ) ) { String altQ = solrParams . get ( ALTQ ) ; if ( altQ != null ) { altQParser = subQuery ( altQ , null ) ; altUserQuery = altQParser . getQuery ( ) ; query . add ( altUserQuery , MUST ) ; } else { return null ; } } else { boolean lowercaseOperators = solrParams . getBool ( "lowercaseOperators" , true ) ; String mainUserQuery = userQuery ; ExtendedDismaxQParser . ExtendedSolrQueryParser up = new ExtendedDismaxQParser . ExtendedSolrQueryParser ( this , ExtendedDismaxQParser . IMPOSSIBLE_FIELD_NAME ) ; up . addAlias ( ExtendedDismaxQParser . IMPOSSIBLE_FIELD_NAME , tiebreaker , queryFields ) ; addAliasesFromRequest ( up , tiebreaker ) ; up . setPhraseSlop ( qslop ) ; up . setAllowLeadingWildcard ( true ) ; List < ExtendedDismaxQParser . Clause > clauses = null ; int numPluses = 0 ; int numMinuses = 0 ; int numOR = 0 ; int numNOT = 0 ; clauses = splitIntoClauses ( userQuery , false ) ; for ( ExtendedDismaxQParser . Clause clause : clauses ) { if ( ( clause . must ) == '+' ) numPluses ++ ; if ( ( clause . must ) == '-' ) numMinuses ++ ; if ( clause . isBareWord ( ) ) { String s = clause . val ; if ( "OR" . equals ( s ) ) { numOR ++ ; } else if ( "NOT" . equals ( s ) ) { numNOT ++ ; } else if ( lowercaseOperators && ( "or" . equals ( s ) ) ) { numOR ++ ; } } } StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < ( clauses . size ( ) ) ; i ++ ) { ExtendedDismaxQParser . Clause clause = clauses . get ( i ) ; String s = clause . raw ; <START_BUG> if ( ( i > 0 ) && ( ( i + 1 ) < ( clauses . size ( ) ) ) ) { <END_BUG> if ( "AND" . equalsIgnoreCase ( s ) ) { s = "AND" ; } else if ( "OR" . equalsIgnoreCase ( s ) ) { s = "OR" ; } } sb . append ( s ) ; sb . append ( '<seq2seq4repair_space>' ) ; } mainUserQuery = sb . toString ( ) ; boolean doMinMatched = ( ( ( numOR + numNOT ) + numPluses ) + numMinuses ) == 0 ; try { up . setRemoveStopFilter ( ( ! stopwords ) ) ; up . exceptions = true ; parsedUserQuery = up . parse ( mainUserQuery ) ; if ( stopwords && ( ExtendedDismaxQParser . isEmpty ( parsedUserQuery ) ) ) { up . setRemoveStopFilter ( true ) ; parsedUserQuery = up . parse ( mainUserQuery ) ; } } catch ( Exception e ) { up . exceptions = false ; } if ( ( ( parsedUserQuery ) != null ) && doMinMatched ) { if ( ( parsedUserQuery ) instanceof BooleanQuery ) { SolrPluginUtils . setMinShouldMatch ( ( ( BooleanQuery ) ( parsedUserQuery ) ) , minShouldMatch ) ; } } if ( ( parsedUserQuery ) == null ) { sb = new StringBuilder ( ) ; for ( ExtendedDismaxQParser . Clause clause : clauses ) { boolean doQuote = clause . isPhrase ; String s = clause . val ; if ( ( ! ( clause . isPhrase ) ) && ( ( ( "OR" . equals ( s ) ) || ( "AND" . equals ( s ) ) ) || ( "NOT" . equals ( s ) ) ) ) { doQuote = true ; } if ( ( clause . must ) != 0 ) { sb . append ( clause . must ) ; } if ( ( clause . field ) != null ) { sb . append ( clause . field ) ; sb . append ( ':' ) ; } if ( doQuote ) { sb . append ( '"' ) ;

Fix:
if ( ( lowercaseOperators && ( i > 0 ) ) && ( ( i + 1 ) < ( clauses . size ( ) ) ) ) {