1
0

from.asciidoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 <<esql-multi-index, 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 <<esql-cross-clusters, 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. Use the optional `METADATA` directive to enable <<esql-metadata-fields,metadata fields>>:
  60. [source,esql]
  61. ----
  62. FROM employees METADATA _id
  63. ----
  64. Use enclosing double quotes (`"`) or three enclosing double quotes (`"""`) to escape index names
  65. that contain special characters:
  66. [source,esql]
  67. ----
  68. FROM "this=that", """this[that"""
  69. ----