question: private MLTResult buildQueryForField ( String fieldName , PriorityQueue < MLTTerm > q , BooleanQuery query , boolean contentStreamQuery ) { List < MLTTerm > interestingTerms = new ArrayList < MLTTerm > ( ) ; int qterms = 0 ; int maxTerms = maxQueryTermsPerField ; if ( maxTerms <= 0 ) { maxTerms = Integer . MAX_VALUE ; } BooleanQuery tmpQuery = new BooleanQuery ( ) ; double sumQuaredBoost = 0.0f ; MLTTerm cur ; while ( ( cur = q . pop ( ) ) != null ) { Query tq = null ; final Term term = new Term ( cur . getFieldName ( ) , cur . getWord ( ) ) ; if ( isPayloadField ( cur . getFieldName ( ) ) ) { tq = new PayloadTermQuery ( term , new AveragePayloadFunction ( ) , true ) ; } else { tq = new TermQuery ( term ) ; } if ( boost ) { float boost = cur . getScore ( ) ; tq . setBoost ( boost ) ; sumQuaredBoost += boost * boost ; } else { sumQuaredBoost += 1.0 ; } try { tmpQuery . add ( tq , BooleanClause . Occur . SHOULD ) ; interestingTerms . add ( cur ) ; qterms ++ ; } catch ( BooleanQuery . TooManyClauses ignore ) { break ; } if ( qterms >= maxTerms ) { break ; } } double vectorLength = Math . sqrt ( sumQuaredBoost ) ; if ( vectorLength <= 0.0 ) { return new MLTResult ( interestingTerms , query ) ; } buildBoostedNormalizedQuery ( fieldName , tmpQuery , query , vectorLength , contentStreamQuery ) ; return new MLTResult ( interestingTerms , query ) ; }
target:  Build the More queryFromDocuments query from a PriorityQueue and an initial Boolean query