title: Solr search(sort) by having count
body: <p>Is it possible to search in Solr like in mysql by having count?</p>
  
  <pre><code>SELECT 
      u.* 
  FROM user u
  LEFT JOIN post p ON p.user_id = u.id
  GROUP BY u.id
  HAVING COUNT(p.id) &lt; 10
  </code></pre>
  
  <p>I have schema with next fields: id, type, data
  If I add new field "posts_count" I can write next query:</p>
  
  <pre><code>q=type:user AND posts_count:[0 TO 9]
  </code></pre>
  
  <p>But I can't add new field(for internal reasons)</p>
  
  <p>And next similar question. Is it possible to sort by calculated count</p>
  
  <pre><code>ORDER BY count(p.id) DESC
  q=type:user&amp;sort=posts_count DESC
  </code></pre>
  
  <p><strong>Solr version 6.6</strong></p>
  
  <p><em>p.s. I'm pretty new in Solr</em></p>