keep.asciidoc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. [discrete]
  2. [[esql-keep]]
  3. === `KEEP`
  4. **Syntax**
  5. [source,esql]
  6. ----
  7. KEEP columns
  8. ----
  9. *Parameters*
  10. `columns`::
  11. A comma-separated list of columns to keep. Supports wildcards.
  12. *Description*
  13. The `KEEP` processing command enables you to specify what columns are returned
  14. and the order in which they are returned.
  15. *Examples*
  16. The columns are returned in the specified order:
  17. [source.merge.styled,esql]
  18. ----
  19. include::{esql-specs}/docs.csv-spec[tag=keep]
  20. ----
  21. [%header.monospaced.styled,format=dsv,separator=|]
  22. |===
  23. include::{esql-specs}/docs.csv-spec[tag=keep-result]
  24. |===
  25. Rather than specify each column by name, you can use wildcards to return all
  26. columns with a name that matches a pattern:
  27. [source,esql]
  28. ----
  29. include::{esql-specs}/docs.csv-spec[tag=keepWildcard]
  30. ----
  31. The asterisk wildcard (`*`) by itself translates to all columns that do not
  32. match the other arguments. This query will first return all columns with a name
  33. that starts with `h`, followed by all other columns:
  34. [source,esql]
  35. ----
  36. include::{esql-specs}/docs.csv-spec[tag=keepDoubleWildcard]
  37. ----