So I have a solr result with the following JSON:
{
"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"
}
]
}
}
]
}
}
}
The field definitions of the relevant fields are:
<field name="id" type="string" indexed="true" stored="true" required="true" />
<field name="date" type="tdate" indexed="true" stored="true"/>
<field name="status" type="string" indexed="true" stored="true"/>
The field types of "string" and "tdate" types are as follows:
<fieldType name="string" class="solr.StrField"
positionIncrementGap="100"/></fieldType>
<fieldType name="tdate" class="solr.TrieDateField" precisionStep="6"
positionIncrementGap="0"/></fieldType>
The above query is generated by the following grouping parameter:
group=true& group.field=id& group.sort=date desc & group.limit=10
I wish to do the following:
Run a query that includes only includes those groups that contain documents that are not "cancelled".
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".
This is done by sorting the group by the date field and checking the status of the first document.
In the above example, I do not want to include the first group as the status field of its latest document has value : "cancel".
However I want the second group to be included as the status field of its latest document has value : "shipped" and not "cancel".
Any ideas how to do this?
Any help would be much appreciated.