private PriorityQueue<ScoreTerm> createQueue(Map<String,Int> words,String... fieldNames) throws IOException {
  int numDocs=ir.numDocs();
  final int limit=Math.min(maxQueryTerms,words.size());
  FreqQ queue=new FreqQ(limit);
  for (  String word : words.keySet()) {
    int tf=words.get(word).x;
    if (minTermFreq > 0 && tf < minTermFreq) {
      continue;
    }
    String topField=fieldNames[0];
    int docFreq=0;
    for (    String fieldName : fieldNames) {
      int freq=ir.docFreq(new Term(fieldName,word));
      topField=(freq > docFreq) ? fieldName : topField;
      docFreq=(freq > docFreq) ? freq : docFreq;
    }
    if (minDocFreq > 0 && docFreq < minDocFreq) {
      continue;
    }
    if (docFreq > maxDocFreq) {
      continue;
    }
    if (docFreq == 0) {
      continue;
    }
    float idf=similarity.idf(docFreq,numDocs);
    float score=tf * idf;
    if (queue.size() < limit) {
      queue.add(new ScoreTerm(word,topField,score,idf,docFreq,tf));
    }
 else {
      ScoreTerm term=queue.top();
      if (term.score < score) {
        term.update(word,topField,score,idf,docFreq,tf);
        queue.updateTop();
      }
    }
  }
  return queue;
}

private PriorityQueue < ScoreTerm > createQueue ( Map < String , Int > words , String ... fieldNames ) throws IOException { int numDocs = ir . numDocs ( ) ; final int limit = Math . min ( maxQueryTerms , words . size ( ) ) ; FreqQ queue = new FreqQ ( limit ) ; for ( String word : words . keySet ( ) ) { int tf = words . get ( word ) . x ; if ( minTermFreq > 0 && tf < minTermFreq ) { continue ; } String topField = fieldNames [ 0 ] ; int docFreq = 0 ; for ( String fieldName : fieldNames ) { int freq = ir . docFreq ( new Term ( fieldName , word ) ) ; topField = ( freq > docFreq ) ? fieldName : topField ; docFreq = ( freq > docFreq ) ? freq : docFreq ; } if ( minDocFreq > 0 && docFreq < minDocFreq ) { continue ; } if ( docFreq > maxDocFreq ) { continue ; } if ( docFreq == 0 ) { continue ; } float idf = similarity . idf ( docFreq , numDocs ) ; float score = tf * idf ; if ( queue . size ( ) < limit ) { queue . add ( new ScoreTerm ( word , topField , score , idf , docFreq , tf ) ) ; } else { ScoreTerm term = queue . top ( ) ; if ( term . score < score ) { term . update ( word , topField , score , idf , docFreq , tf ) ; queue . updateTop ( ) ; } } } return queue ; }
create a priorityqueue from a word - > tf map .
