Skip to main content

Sort

Every search result can be sorted by a number of fields. Sort order is either ascending (asc) or descending (desc). If no order is defined, the default is ascending.

The syntax to define a sort is:

sort path.to.property [asc|desc]

It is possible to define multiple sort criteria:

is(volume) sort kind, volume_size desc, name asc

Searches performed on the CLI will automatically sort the results by default using following sort criteria:

sort kind asc, name asc, id asc

Limit

It is possible to define a limit on the search result. The limit is defined by an optional offset and the number of results to return.

Examples
Limit to 10 results
is(volume) limit 10
Limit to 5 results, skipping the first 3
is(volume) limit 3, 5

While experimenting with a specific search or exploring the cloud, you should always define a meaningful limit. This will reduce the search result to a number that can be digested easily.

note

A single search can have multiple limits: one for each partial search result. This is especially useful when the graph is traversed, since the limit can be applied to every graph traversal.

Example
is(volume) limit 5,1 <-- is(instance) limit 1 <-- is(load_balancer) limit 1

Let's analyze the different limits one by one:

  • Filter all volumes and limit the result to one example, while skipping the first 5 results.
  • From this node, walk the graph inbound and filter the list of nodes by type instance, again limiting the result to one example.
  • Continue walking the graph inbound, filter the list of nodes by type load_balancer, and limit the result once more to one example.

The final result is exactly zero or one load balancer (depending on the structure of the graph). The performance of the search is excellent, since only a small number of nodes need to be traversed.