code: private PriorityQueue<Object[]> createQueue(Map<String, Int> words) throws IOException
     {
        // have collected all words in doc and their freqs
        int numDocs = ir.numDocs();
        FreqQ res = new FreqQ(words.size()); // will order words by score
  
        Iterator<String> it = words.keySet().iterator();
        while (it.hasNext())
        { // for every word
           String word = it.next();
  
           int tf = words.get(word).x; // term freq in the source doc
           if (minTermFreq > 0 && tf < minTermFreq)
           {
              continue; // filter out words that don't occur enough times in the source
           }
  
           // go through all the fields and find the largest document frequency
           String topField = fieldNames[0];
           int docFreq = 0;
           for (int i = 0; i < fieldNames.length; i++)
           {
              int freq = ir.docFreq(new Term(fieldNames[i], word));
              topField = (freq > docFreq) ? fieldNames[i] : topField; //NOSONAR
              docFreq = (freq > docFreq) ? freq : docFreq;
           }
  
           if (minDocFreq > 0 && docFreq < minDocFreq)
           {
              continue; // filter out words that don't occur in enough docs
           }
  
           if (docFreq == 0)
           {
              continue; // index update problem?
           }
  
           float idf = similarity.idf(docFreq, numDocs);
           float score = tf * idf;
  
           // only really need 1st 3 entries, other ones are for troubleshooting
           res.insertWithOverflow(new Object[]{word, // the word
              topField, // the top field
              new Float(score), // overall score
              new Float(idf), // idf
              new Integer(docFreq), // freq in all docs
              new Integer(tf)});
        }
        return res;
     }
docs: Create a PriorityQueue<Object[]> from a word->tf map.
  
  @param words a map of words keyed on the word(String) with Int objects as the values.