Source:
<code>private static JsonObject convertBooleanQuery(BooleanQuery booleanQuery) { JsonArray musts = new JsonArray(); JsonArray shoulds = new JsonArray(); JsonArray mustNots = new JsonArray(); JsonArray filters = new JsonArray(); for ( BooleanClause clause : booleanQuery.clauses() ) { switch ( clause.getOccur() ) { case MUST: musts.add( fromLuceneQuery( clause.getQuery() ) ); break; case FILTER: filters.add( fromLuceneQuery( clause.getQuery() ) ); break; case MUST_NOT: mustNots.add( fromLuceneQuery( clause.getQuery() ) ); break; case SHOULD: shoulds.add( fromLuceneQuery( clause.getQuery() ) ); break; } } JsonBuilder.Object clauses = JsonBuilder.object(); if ( musts.size() > 1 ) { clauses.add( "must", musts ); } else if ( musts.size() == 1 ) { clauses.add( "must", musts.iterator().next() ); } if ( shoulds.size() > 1 ) { clauses.add( "should", shoulds ); } else if ( shoulds.size() == 1 ) { clauses.add( "should", shoulds.iterator().next() ); } if ( mustNots.size() > 1 ) { clauses.add( "must_not", mustNots ); } else if ( mustNots.size() == 1 ) { clauses.add( "must_not", mustNots.iterator().next() ); } if ( filters.size() > 1 ) { clauses.add( "filter", filters ); } else if ( filters.size() == 1 ) { clauses.add( "filter", filters.iterator().next() ); } clauses.append( boostAppender( booleanQuery ) ); <START> int minimumShouldMatch = booleanQuery.getMinimumNumberShouldMatch(); <END> if ( minimumShouldMatch != 0 ) { clauses.addProperty( "minimum_should_match", minimumShouldMatch ); } JsonObject bool = new JsonObject(); bool.add( "bool", clauses.build() ); return bool; }</code><technical_language>call minimumShouldMatchNumber number end elsewhere</technical_language>

Target:
private static JsonObject convertBooleanQuery(BooleanQuery booleanQuery) { JsonArray musts = new JsonArray(); JsonArray shoulds = new JsonArray(); JsonArray mustNots = new JsonArray(); JsonArray filters = new JsonArray(); for ( BooleanClause clause : booleanQuery.clauses() ) { switch ( clause.getOccur() ) { case MUST: musts.add( fromLuceneQuery( clause.getQuery() ) ); break; case FILTER: filters.add( fromLuceneQuery( clause.getQuery() ) ); break; case MUST_NOT: mustNots.add( fromLuceneQuery( clause.getQuery() ) ); break; case SHOULD: shoulds.add( fromLuceneQuery( clause.getQuery() ) ); break; } } JsonBuilder.Object clauses = JsonBuilder.object(); if ( musts.size() > 1 ) { clauses.add( "must", musts ); } else if ( musts.size() == 1 ) { clauses.add( "must", musts.iterator().next() ); } if ( shoulds.size() > 1 ) { clauses.add( "should", shoulds ); } else if ( shoulds.size() == 1 ) { clauses.add( "should", shoulds.iterator().next() ); } if ( mustNots.size() > 1 ) { clauses.add( "must_not", mustNots ); } else if ( mustNots.size() == 1 ) { clauses.add( "must_not", mustNots.iterator().next() ); } if ( filters.size() > 1 ) { clauses.add( "filter", filters ); } else if ( filters.size() == 1 ) { clauses.add( "filter", filters.iterator().next() ); } clauses.append( boostAppender( booleanQuery ) ); int minimumShouldMatchNumber = booleanQuery.getMinimumNumberShouldMatch(); if ( minimumShouldMatchNumber != 0 ) { clauses.addProperty( "minimum_should_match", minimumShouldMatchNumber ); } JsonObject bool = new JsonObject(); bool.add( "bool", clauses.build() ); return bool; }