Skip to content

Sorting by multiple facets #3638

@KevOrr

Description

@KevOrr

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:

{
  asdf(func: has(DOB), orderasc: DOB, orderasc: name) {
    uid
    DOB
    name
  }
}

It would be nice if we could lexicographically sort by multiple facets in the same way:

{
  asdf(func: has(edge)) {
    uid
    edge @facets(kind, index, orderasc: kind, orderasc: index) {
      uid
    }
  }
}

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

Metadata

Metadata

Labels

area/facetsIssues related to face handling, querying, etc.exp/beginnerSomething most people could solve.kind/enhancementSomething could be better.status/acceptedWe accept to investigate/work on it.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions