from.asciidoc 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. [discrete]
  2. [[esql-from]]
  3. === `FROM`
  4. The `FROM` source command returns a table with data from a data stream, index,
  5. or alias.
  6. **Syntax**
  7. [source,esql]
  8. ----
  9. FROM index_pattern [METADATA fields]
  10. ----
  11. *Parameters*
  12. `index_pattern`::
  13. A list of indices, data streams or aliases. Supports wildcards and date math.
  14. `fields`::
  15. A comma-separated list of <<esql-metadata-fields,metadata fields>> to retrieve.
  16. *Description*
  17. The `FROM` source command returns a table with data from a data stream, index,
  18. or alias. Each row in the resulting table represents a document. Each column
  19. corresponds to a field, and can be accessed by the name of that field.
  20. [NOTE]
  21. ====
  22. By default, an {esql} query without an explicit <<esql-limit>> uses an implicit
  23. limit of 1000. This applies to `FROM` too. A `FROM` command without `LIMIT`:
  24. [source,esql]
  25. ----
  26. FROM employees
  27. ----
  28. is executed as:
  29. [source,esql]
  30. ----
  31. FROM employees
  32. | LIMIT 1000
  33. ----
  34. ====
  35. *Examples*
  36. [source,esql]
  37. ----
  38. FROM employees
  39. ----
  40. You can use <<api-date-math-index-names,date math>> to refer to indices, aliases
  41. and data streams. This can be useful for time series data, for example to access
  42. today's index:
  43. [source,esql]
  44. ----
  45. FROM <logs-{now/d}>
  46. ----
  47. Use comma-separated lists or wildcards to query multiple data streams, indices,
  48. or aliases:
  49. [source,esql]
  50. ----
  51. FROM employees-00001,other-employees-*
  52. ----
  53. Use the format `<remote_cluster_name>:<target>` to query data streams and indices
  54. on remote clusters:
  55. [source,esql]
  56. ----
  57. FROM cluster_one:employees-00001,cluster_two:other-employees-*
  58. ----
  59. See <<esql-cross-clusters, using {esql} across clusters>>.
  60. Use the optional `METADATA` directive to enable <<esql-metadata-fields,metadata fields>>:
  61. [source,esql]
  62. ----
  63. FROM employees METADATA _id
  64. ----
  65. Use enclosing double quotes (`"`) or three enclosing double quotes (`"""`) to escape index names
  66. that contain special characters:
  67. [source,esql]
  68. ----
  69. FROM "this=that", """this[that"""
  70. ----