-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sorting by multiple facets #3638
Comments
This seems like a pretty straight forward request that makes total sense. We'll consider it for the roadmap in v1.2. Thanks for the report, @KevOrr ! |
Just a kind of "note" update on this: After rereading this issue. I noticed that we could try another way*. However, the problem continues even after trying to reproduce. In fact the result is even worse because Query{
F as var(func: eq(name, "Carol Lelvits")) {
var : friend @facets(close, kind, index, K as since)
}
q(func: uid(F)) {
uid
friend(orderasc: val(K)) @facets(close, kind, index, since) {
uid
name
val(K) # Note that the value in this variable comes in order, but the nodes themselves do not.
}
}
} Result{
"data": {
"q": [
{
"uid": "0x2711",
"friend": [
{
"uid": "0x2715",
"name": "Daryl",
"val(K)": "2001-01-01T00:00:00Z",
"friend|close": "true",
"friend|index": "1",
"friend|kind": "Childhood",
"friend|since": "2002-01-01T00:00:00Z"
},
{
"uid": "0x2712",
"name": "Lily",
"val(K)": "2002-01-01T00:00:00Z",
"friend|close": "false",
"friend|index": "2",
"friend|kind": "School",
"friend|since": "2011-01-01T00:00:00Z"
},
{
"uid": "0x2713",
"name": "Lucas",
"val(K)": "2011-01-01T00:00:00Z",
"friend|close": "false",
"friend|index": "3",
"friend|kind": "School",
"friend|since": "2011-01-01T00:00:00Z"
},
{
"uid": "0x2714",
"name": "Junior",
"val(K)": "2011-01-01T00:00:00Z",
"friend|close": "true",
"friend|index": "0",
"friend|kind": "Childhood",
"friend|since": "2001-01-01T00:00:00Z"
}
]
}
]
}
} Dataset{
"set": [
{
"name": "Carol Lelvits",
"name|initial": "C",
"friend": [{
"name": "Daryl",
"friend|close": "true",
"friend|index": "0",
"friend|kind": "Childhood",
"friend|since": "2001"
},
{
"name": "Lily",
"friend|close": "true",
"friend|index": "1",
"friend|kind": "Childhood",
"friend|since": "2002"
},
{
"name": "Lucas",
"friend|close": "false",
"friend|index": "2",
"friend|kind": "School",
"friend|since": "2011"
},
{
"name": "Junior",
"friend|close": "false",
"friend|index": "3",
"friend|kind": "School",
"friend|since": "2011"
}
]
}
]
} |
Another user requested this via https://discuss.dgraph.io/t/do-facets-support-multi-sorting/5587/4 |
Fixes: #3638 Currently, we can specify ordering only on single facet while retrieving facets on uid predicates. This PR adds support for specifying ordering on more than one facets.
Hey @KevOrr, we have merged PR for this change in master. Please let us know you feedback. |
Experience Report
Note: Feature requests are judged based on user experience and modeled on Go Experience Reports. These reports should focus on the problems: they should not focus on and need not propose solutions.
What you wanted to do
You can use
orderasc
to sort by multiple predicates, which will combine their orderings using lexicographic ordering:It would be nice if we could lexicographically sort by multiple facets in the same way:
What you actually did
Sort by one facet, and then sort by the other on the client side, or leave unsorted and handle all sorting client-side.
Why that wasn't great, with examples
In complex, deeply nested queries, it can be cumbersome to post-process results. It divides the intended query into two steps: the actual query, and then a sorting phase. This is trickier to maintain. Besides, graphql(+-) already lends itself nicely to things such as sorting.
Any external references to support your case
https://discuss.dgraph.io/t/sorting-by-multiple-facets/4670
The text was updated successfully, but these errors were encountered: