@Override public Query rewrite(IndexReader reader) throws IOException {
  if (disjuncts.length == 1) {
    return disjuncts[0];
  }
  boolean actuallyRewritten=false;
  List<Query> rewrittenDisjuncts=new ArrayList<>();
  for (  Query sub : disjuncts) {
    Query rewrittenSub=sub.rewrite(reader);
    actuallyRewritten|=rewrittenSub != sub;
    rewrittenDisjuncts.add(rewrittenSub);
  }
  if (actuallyRewritten) {
    return new DisjunctionMaxQuery(rewrittenDisjuncts,tieBreakerMultiplier);
  }
  return super.rewrite(reader);
}

@ Override public Query rewrite ( IndexReader reader ) throws IOException { if ( disjuncts . length == 1 ) { return disjuncts [ 0 ] ; } boolean actuallyRewritten = false ; List < Query > rewrittenDisjuncts = new ArrayList < > ( ) ; for ( Query sub : disjuncts ) { Query rewrittenSub = sub . rewrite ( reader ) ; actuallyRewritten |= rewrittenSub != sub ; rewrittenDisjuncts . add ( rewrittenSub ) ; } if ( actuallyRewritten ) { return new DisjunctionMaxQuery ( rewrittenDisjuncts , tieBreakerMultiplier ) ; } return super . rewrite ( reader ) ; }
optimize our representation and our subqueries representations
