ElasticGraph Query API: Sorting
Try these example queries by visiting the GraphiQL UI after booting locally.
Copied!
$ curl -s https://block.github.io/elasticgraph/dc.yml | docker compose -f - up --pull always
Use orderBy:
on a root query field to control how the results are sorted:
Copied!
query ListArtists {
artists(orderBy: [name_ASC, bio_yearFormed_DESC]) {
nodes {
name
albums {
name
}
}
}
}
This query, for example, would sort by name
(ascending), with bio.yearFormed
(descending) as a tie breaker.
When no orderBy:
argument is provided, ElasticGraph will sort according to the
default sort configured on the index.