title: How to facet (group) over two fields in Apache Solr
body: <p>I have a requirement to facet my data over two fields in Apache Solr.</p>
  
  <p>The fields in my loginhistory schema are user_id, city, status, time. I want to find out the number of users logged in from a particular city and for a particular status in a given time frame.</p>
  
  <p>For example, output of my query should show the following:</p>
  
  <blockquote>
    <p>City  Status  Count<br>
    NY  SUCCESS   43  NY  FAILURE   10  NY INP 32  LA  SUCCESS   65  LA  FAILURE   12 ..............</p>
  </blockquote>
  
  <p>Here is the sample query that facet over city field for a given time frame.</p>
  
  <p><a href="http://localhost:8983/solr/query?q=status:SUCCESS%20AND%20time:2015-12-20T16:13:00Z+TO+2015-12-20T16:13:20Z&amp;facet=true&amp;facet.field=city" rel="nofollow">http://localhost:8983/solr/query?q=status:SUCCESS%20AND%20time:2015-12-20T16:13:00Z+TO+2015-12-20T16:13:20Z&amp;facet=true&amp;facet.field=city</a></p>