title: Getting most frequent terms in a subset of indexed lucene documents
body: <p>Let's assume the following scenario. </p>
  
  <ul>
  <li><p>Lucene document: ArticleDocument </p>
  
  <p>Fields: {Id, text, publisherId}</p></li>
  <li><p>A publisher can publish multiple articles. </p></li>
  </ul>
  
  <p><strong>Problem</strong></p>
  
  <p>I would like to build word clouds (most frequent words, shingles) for each <strong><em>Publisher Id</em></strong>. </p>
  
  <p>After my investigation, I could find ways to get most frequent terms for the entire Index or a document but not for <em>a subset of documents.</em> I found a <a href="https://stackoverflow.com/questions/195434/how-can-i-get-top-terms-for-a-subset-of-documents-in-a-lucene-index">similar question</a> but that's Lucene 2.x and I'm hoping there exists an effective way in recent Lucene.</p>
  
  <p>Please could you guide me with a way to perform that in <strong>Lucene 4.x</strong> (preferred) or 3.x (latest in version 3). </p>
  
  <p>Please note that I cannot make each Publisher a document with all the articles being appended to a field. </p>
  
  <p>That's because I would like to have those words in the cloud to be searchable with corresponding articles (by same publisher id) being the results. </p>
  
  <p>I'm not sure whether maintaining two types of lucene documents (article and publisher) is a good idea in terms of maintenance and performance.</p>