Hello, I have a question about using multiple sorting in DQL. I want to sort the recommendation results based on two values, val(score) and last_ts, in order to recommend posts. Here is the query that I’m using:
{
var(func: has(reaction_id)) @filter(ge(last_ts,"2022-05-08")) {
reaction_id
rr as rate
send_to @filter(eq(status,"true")) {
candidate as post_id
score as math(rr)
}
}
recommend(func: uid(candidate), orderdesc: val(score), orderdesc: last_ts, first: 100) {
post_id
score: val(score)
last_ts
}
}
However, the last_ts sorting doesn’t seem to be working properly when I input the query. The result is as follows:
{
"data": {
"recommend": [
...
{
"post_id": "55102",
"score": 26,
"last_ts": "2023-05-08T16:30:33Z"
},
{
"post_id": "81102",
"score": 26,
"last_ts": "2023-05-08T16:30:58Z"
},
{
"post_id": "84902",
"score": 26,
"last_ts": "2023-05-08T16:31:02Z"
},
{
"post_id": "35202",
"score": 26,
"last_ts": "2023-05-08T16:30:15Z"
},
{
"post_id": "72802",
"score": 26,
"last_ts": "2023-05-08T16:30:50Z"
},
{
"post_id": "64602",
"score": 25,
"last_ts": "2023-05-08T16:30:42Z"
},
{
"post_id": "15102",
"score": 25,
"last_ts": "2023-05-08T16:29:56Z"
},
{
"post_id": "30502",
"score": 25,
"last_ts": "2023-05-08T16:30:10Z"
},
{
"post_id": "36402",
"score": 25,
"last_ts": "2023-05-08T16:30:16Z"
},
{
"post_id": "20902",
"score": 25,
"last_ts": "2023-05-08T16:30:01Z"
},
{
"post_id": "87602",
"score": 25,
"last_ts": "2023-05-08T16:31:04Z"
},
{
"post_id": "88502",
"score": 24,
"last_ts": "2023-05-08T16:31:05Z"
},
{
"post_id": "46802",
"score": 24,
"last_ts": "2023-05-08T16:30:26Z"
},
{
"post_id": "84802",
"score": 24,
"last_ts": "2023-05-08T16:31:01Z"
},
{
"post_id": "64202",
"score": 24,
"last_ts": "2023-05-08T16:30:42Z"
},
{
"post_id": "21702",
"score": 24,
"last_ts": "2023-05-08T16:30:02Z"
},
{
"post_id": "41102",
"score": 24,
"last_ts": "2023-05-08T16:30:20Z"
},
{
"post_id": "54202",
"score": 24,
"last_ts": "2023-05-08T16:30:32Z"
},
{
"post_id": "62002",
"score": 24,
"last_ts": "2023-05-08T16:30:40Z"
},
{
"post_id": "85002",
"score": 23,
"last_ts": "2023-05-08T16:31:02Z"
},
{
"post_id": "22602",
"score": 23,
"last_ts": "2023-05-08T16:30:03Z"
},
{
"post_id": "82402",
"score": 23,
"last_ts": "2023-05-08T16:30:59Z"
},
{
"post_id": "34802",
"score": 23,
"last_ts": "2023-05-08T16:30:15Z"
},
{
"post_id": "79302",
"score": 23,
"last_ts": "2023-05-08T16:30:56Z"
},
{
"post_id": "10802",
"score": 23,
"last_ts": "2023-05-08T17:08:20Z"
},
{
"post_id": "59502",
"score": 23,
"last_ts": "2023-05-08T16:30:37Z"
},
{
"post_id": "24402",
"score": 23,
"last_ts": "2023-05-08T16:30:04Z"
},
{
"post_id": "40202",
"score": 23,
"last_ts": "2023-05-08T16:30:20Z"
},
{
"post_id": "75202",
"score": 23,
"last_ts": "2023-05-08T16:30:52Z"
},
{
"post_id": "33202",
"score": 23,
"last_ts": "2023-05-08T16:30:13Z"
},
{
"post_id": "40302",
"score": 23,
"last_ts": "2023-05-08T16:30:20Z"
},
{
"post_id": "83302",
"score": 22,
"last_ts": "2023-05-08T16:31:00Z"
},
{
"post_id": "87702",
"score": 22,
"last_ts": "2023-05-08T16:31:04Z"
},
{
"post_id": "73802",
"score": 22,
"last_ts": "2023-05-08T16:30:51Z"
},
{
"post_id": "79802",
"score": 22,
"last_ts": "2023-05-08T16:30:56Z"
},
{
"post_id": "60702",
"score": 22,
"last_ts": "2023-05-08T16:30:39Z"
},
{
"post_id": "27902",
"score": 22,
"last_ts": "2023-05-08T16:30:08Z"
},
{
"post_id": "12102",
"score": 22,
"last_ts": "2023-05-08T16:29:53Z"
},
{
"post_id": "16002",
"score": 22,
"last_ts": "2023-05-08T16:29:56Z"
},
{
"post_id": "31602",
"score": 22,
"last_ts": "2023-05-08T16:30:11Z"
},
{
"post_id": "82202",
"score": 22,
"last_ts": "2023-05-08T16:30:59Z"
},
{
"post_id": "52802",
"score": 22,
"last_ts": "2023-05-08T16:30:31Z"
},
{
"post_id": "62202",
"score": 22,
"last_ts": "2023-05-08T16:30:40Z"
},
{
"post_id": "20102",
"score": 22,
"last_ts": "2023-05-08T16:30:00Z"
},
{
"post_id": "60402",
"score": 22,
"last_ts": "2023-05-08T16:30:38Z"
},
{
"post_id": "74402",
"score": 22,
"last_ts": "2023-05-08T16:30:51Z"
},
{
"post_id": "24002",
"score": 22,
"last_ts": "2023-05-08T16:30:04Z"
},
{
"post_id": "37902",
"score": 22,
"last_ts": "2023-05-08T16:30:17Z"
},
{
"post_id": "20702",
"score": 22,
"last_ts": "2023-05-08T16:30:01Z"
},
...
My question is whether the tokenizer is set to hour, and if that is why only the hour value is being sorted. I would appreciate your answer. Thank you.