Conversation
Update SORT command docs to state that sort keys can be any expression (column, function, or arithmetic), not only column names. Add syntax, parameter description, and a 'Sort by expression' example. Align limitations.md wording with expression terminology. Fixes #115011 Made-with: Cursor
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
🔍 Preview links for changed docs |
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version. We use applies_to tags to mark version-specific features and changes. Expand for a quick overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
docs/reference/query-languages/esql/_snippets/commands/layout/sort.md
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Updates the ES|QL documentation to reflect that SORT supports sorting by arbitrary expressions (not just column names), aligning docs with the feature introduced in 8.14.0.
Changes:
- Update
SORTcommand intro/syntax/parameter wording from “column” to “expression”, and add an example showing sorting by an expression. - Adjust ES|QL limitations wording to match the updated
SORT“expression” terminology.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| docs/reference/query-languages/esql/limitations.md | Updates SORT limitation wording to refer to expressions evaluating to spatial types. |
| docs/reference/query-languages/esql/_snippets/commands/layout/sort.md | Documents expression-based sorting, updates syntax/parameter docs, and adds a “Sort by expression” example. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| [function](/reference/query-languages/esql/esql-functions-operators.md#esql-functions) (for example, | ||
| `length(field)`, `year(date)`), or an arithmetic expression (for example, `salary * 2`). | ||
| The expression is evaluated per row and the result is used for ordering. |
There was a problem hiding this comment.
year(date) is not an ES|QL function in this docs set (existing docs use DATE_EXTRACT("year", date) for year extraction). Using year(date) here will mislead readers and makes the example inconsistent with the function reference—please replace it with a valid ES|QL date function call (e.g., DATE_EXTRACT("year", date)).
| The `SORT` processing command sorts a table on one or more expressions. You can sort by any | ||
| expression, not only column names—for example, `length(first_name)` or `year(hire_date)`. |
There was a problem hiding this comment.
The description example uses year(hire_date), but there doesn't appear to be an ES|QL year() function in the docs (year extraction is documented via DATE_EXTRACT("year", <date>)). Please update this example to a valid ES|QL function to avoid confusing users.
…sort.md Co-authored-by: Iván Cea Fontenla <ivancea96@outlook.com>
Replace year(date) with DATE_EXTRACT("year", date) so examples
match the documented ES|QL date functions.
Made-with: Cursor
* Document ES|QL SORT by expression Update SORT command docs to state that sort keys can be any expression (column, function, or arithmetic), not only column names. Add syntax, parameter description, and a 'Sort by expression' example. Align limitations.md wording with expression terminology. Fixes elastic#115011 Made-with: Cursor * Update docs/reference/query-languages/esql/_snippets/commands/layout/sort.md Co-authored-by: Iván Cea Fontenla <ivancea96@outlook.com> * Use DATE_EXTRACT for year in SORT expression examples Replace year(date) with DATE_EXTRACT("year", date) so examples match the documented ES|QL date functions. Made-with: Cursor --------- Co-authored-by: Iván Cea Fontenla <ivancea96@outlook.com>
Summary
Documents that the ES|QL
SORTcommand accepts any expression as a sort key, not only column names (feature added in 8.14.0, see #107158).Changes
commands/sort.mdvia layout snippet): Updated intro, syntax, and parameters to use "expression" instead of "column"; clarified that sort keys can be column names, functions (e.g.length(field),year(date)), or arithmetic. Added a Sort by expression example subsection withSORT length(first_name) DESC.Fixes #115011
Made with Cursor