from.asciidoc 2.0 KB

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