metadata-fields.asciidoc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. [[esql-metadata-fields]]
  2. === {esql} metadata fields
  3. ++++
  4. <titleabbrev>Metadata fields</titleabbrev>
  5. ++++
  6. {esql} can access <<mapping-fields, metadata fields>>. The currently
  7. supported ones are:
  8. * <<mapping-index-field,`_index`>>: the index to which the document belongs.
  9. The field is of the type <<keyword, keyword>>.
  10. * <<mapping-id-field,`_id`>>: the source document's ID. The field is of the
  11. type <<keyword, keyword>>.
  12. * `_version`: the source document's version. The field is of the type
  13. <<number,long>>.
  14. * <<mapping-ignored-field,`_ignored`>>: the ignored source document fields. The field is of the type
  15. <<keyword,keyword>>.
  16. To enable the access to these fields, the <<esql-from,`FROM`>> source command needs
  17. to be provided with a dedicated directive:
  18. [source,esql]
  19. ----
  20. FROM index METADATA _index, _id
  21. ----
  22. Metadata fields are only available if the source of the data is an index.
  23. Consequently, `FROM` is the only source commands that supports the `METADATA`
  24. directive.
  25. Once enabled, these fields will be available to subsequent processing commands, just
  26. like other index fields:
  27. [source.merge.styled,esql]
  28. ----
  29. include::{esql-specs}/metadata.csv-spec[tag=multipleIndices]
  30. ----
  31. [%header.monospaced.styled,format=dsv,separator=|]
  32. |===
  33. include::{esql-specs}/metadata.csv-spec[tag=multipleIndices-result]
  34. |===
  35. Similar to index fields, once an aggregation is performed, a
  36. metadata field will no longer be accessible to subsequent commands, unless
  37. used as a grouping field:
  38. [source.merge.styled,esql]
  39. ----
  40. include::{esql-specs}/metadata.csv-spec[tag=metaIndexInAggs]
  41. ----
  42. [%header.monospaced.styled,format=dsv,separator=|]
  43. |===
  44. include::{esql-specs}/metadata.csv-spec[tag=metaIndexInAggs-result]
  45. |===