如何对已经分类的结果进行分类

时间:2019-07-16 18:36:04

标签: solr lucene solrcloud

如何对已经排序的结果进行排序。

要求说明:

  1. 我想将d个相同的物品分组并列出数量更多的物品。

{ “ customerAccountId”:“ cust123”, “ skuNumber”:222, “数量”:10, “ salesDate”:“ 2019-06-10T00:00:00Z”, }

  1. 如果物品数量相等,我希望它们根据销售日期进行排序,以使最近购买的物品排在首位

For #1 I have grouped similar items and aggregate total quantities and sort  -working.
SOLR QUERY:
customerAccountId:cust123&fl=skuNumber&omitHeader=true&wt=json
&json.facet={categories:{type:terms,field:skuNumber,limit:25,offset:0,sort:{quantity:desc},facet:{quantity:"sum(quantity)"}}}

For #2 if all quantities are same , i want them to order on salesdate   -- NEED HELP

Example : suppose this is the data available
{
"customerAccountId": "cust123",
"skuNumber": 111,
"quantity": 1,
"salesDate": "2019-06-10T00:00:00Z",
},

{
"customerAccountId": "cust123",
"skuNumber": 111,
"quantity": 1,
"salesDate": "2019-06-09T00:00:00Z",
},
{
"customerAccountId": "cust123",
"skuNumber": 222,
"quantity": 10,
"salesDate": "2019-07-10T00:00:00Z",
},
{
"customerAccountId": "cust123",
"skuNumber": 222,
"quantity": 1,
"salesDate": "2019-07-10T00:00:00Z",
},
{
"customerAccountId": "cust123",
"skuNumber": 333,
"quantity": 2,
"salesDate": "2019-07-10T00:00:00Z",
},

**期望的响应应按顺序排列

  1. 222(quantity11)
  2. 333(数量2的销售日期为2019-07)
  3. 222(数量2发售日期2019-06)
sample Response:
"facets": {
"count": ,
"categories": {
"buckets": [
{
"val": "222",
"count": 2,
"quantity": 11
},
{
"val": "333",
"count": 1,
"quantity": 2
},
{
"val": "111",
"count": 2,
"quantity": 2
}

0 个答案:

没有答案