title: Solr grouping results
body: <p>So I have a solr result with the following JSON:</p>
  
  <pre><code>{
    "grouped": {
      "manu_exact": {
        "matches": 2,
        "groups": [
          {
            "groupValue": "SOLR1000",
            "doclist": {
              "numFound": 2,
              "start": 0,
              "docs": [
                {
                  "id": "SOLR1000",
                  "name": "Solr, the Enterprise Search Server",
                  "date":"March 1, 2018 03:00:00",
                  "status":"Cancel"
                },
                {
                 "id": "SOLR1000",
                  "name": "Solr, the Enterprise Search Server",
                  "date":"March 1, 2018 01:00:00",
                  "status":"New"
                }
  
              ]
            }
          },
          {
            "groupValue": "VS1GB400C3",
            "doclist": {
              "numFound": 2,
              "start": 0,
              "docs": [
                {
                  "id": "VS1GB400C3",
                  "name": "Retail",
                  "date":"March 4, 2018 04:00:00",
                  "status":"Shipped"
                },
                {
                  "id": "VS1GB400C3",
                  "name": "Retail",
                  "date":"March 4, 2018 02:00:00",
                  "status":"New"
                }
              ]
            }
          }
        ]
      }
    }
  }
  </code></pre>
  
  <p>The field definitions of the relevant fields are:</p>
  
  <pre><code>&lt;field name="id" type="string" indexed="true" stored="true" required="true" /&gt; 
  &lt;field name="date" type="tdate" indexed="true" stored="true"/&gt;
  &lt;field name="status" type="string" indexed="true" stored="true"/&gt;
  </code></pre>
  
  <p>The field types of "string" and "tdate" types are as follows:</p>
  
  <pre><code>&lt;fieldType name="string" class="solr.StrField"
        positionIncrementGap="100"/&gt;&lt;/fieldType&gt;
  &lt;fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" 
        positionIncrementGap="0"/&gt;&lt;/fieldType&gt;
  </code></pre>
  
  <p>The above query is generated by the following grouping parameter:</p>
  
  <p><strong>group=true&amp; group.field=id&amp; group.sort=date desc &amp; group.limit=10</strong></p>
  
  <p>I wish to do the following:</p>
  
  <p>Run a query that includes only includes those groups that contain documents that are not "cancelled". </p>
  
  <p>Basically, the sorted group gives the time line of the status of the product. I only want to retrive the documents that  do not have the latest status as "Cancel". </p>
  
  <p>This is done by sorting the group by the date field and checking the status of the first document.</p>
  
  <p><strong>In the above example, I do not want to include the first group as  the status field of its latest document has value : "cancel".</strong> </p>
  
  <p><strong>However I want the second group to be included as the status field of its latest document has value : "shipped" and not "cancel".</strong></p>
  
  <p>Any ideas how to do this?</p>
  
  <p>Any help would be much appreciated.</p>