Skip to content

Latest commit

 

History

History
99 lines (71 loc) · 2.66 KB

File metadata and controls

99 lines (71 loc) · 2.66 KB

sort

Table of contents

Using sort command to sorts all the search result by the specified fields.

sort <[+|-] sort-field>...

  • [+|-]: optional. The plus [+] for ascending order and a minus [-] for descending order. Default: ascending order.
  • sort-field: mandatory. The field used to sort.

The example show sort all the document with age field in ascending order.

PPL query:

od> source=accounts | sort age | fields account_number, age;
fetched rows / total rows = 4/4
+------------------+-------+
| account_number   | age   |
|------------------+-------|
| 13               | 28    |
| 1                | 32    |
| 18               | 33    |
| 6                | 36    |
+------------------+-------+

The example show sort all the document with age field in ascending order.

PPL query:

od> source=accounts | sort age | fields account_number, age;
fetched rows / total rows = 4/4
+------------------+-------+
| account_number   | age   |
|------------------+-------|
| 13               | 28    |
| 1                | 32    |
| 18               | 33    |
| 6                | 36    |
+------------------+-------+

The example show sort all the document with age field in descending order.

PPL query:

od> source=accounts | sort - age | fields account_number, age;
fetched rows / total rows = 4/4
+------------------+-------+
| account_number   | age   |
|------------------+-------|
| 6                | 36    |
| 18               | 33    |
| 1                | 32    |
| 13               | 28    |
+------------------+-------+

The example show sort all the document with gender field in ascending order and age field in descending.

PPL query:

od> source=accounts | sort + gender, - age | fields account_number, gender, age;
fetched rows / total rows = 4/4
+------------------+----------+-------+
| account_number   | gender   | age   |
|------------------+----------+-------|
| 13               | F        | 28    |
| 6                | M        | 36    |
| 18               | M        | 33    |
| 1                | M        | 32    |
+------------------+----------+-------+