metadata-fields.asciidoc 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. * `_score`: when enabled, the final score assigned to each row matching an ES|QL query. Scoring will be updated when using <<esql-search-functions,full text search functions>>.
  17. To enable the access to these fields, the <<esql-from,`FROM`>> source command needs
  18. to be provided with a dedicated directive:
  19. [source,esql]
  20. ----
  21. FROM index METADATA _index, _id
  22. ----
  23. Metadata fields are only available if the source of the data is an index.
  24. Consequently, `FROM` is the only source commands that supports the `METADATA`
  25. directive.
  26. Once enabled, these fields will be available to subsequent processing commands, just
  27. like other index fields:
  28. [source.merge.styled,esql]
  29. ----
  30. include::{esql-specs}/metadata.csv-spec[tag=multipleIndices]
  31. ----
  32. [%header.monospaced.styled,format=dsv,separator=|]
  33. |===
  34. include::{esql-specs}/metadata.csv-spec[tag=multipleIndices-result]
  35. |===
  36. Similar to index fields, once an aggregation is performed, a
  37. metadata field will no longer be accessible to subsequent commands, unless
  38. used as a grouping field:
  39. [source.merge.styled,esql]
  40. ----
  41. include::{esql-specs}/metadata.csv-spec[tag=metaIndexInAggs]
  42. ----
  43. [%header.monospaced.styled,format=dsv,separator=|]
  44. |===
  45. include::{esql-specs}/metadata.csv-spec[tag=metaIndexInAggs-result]
  46. |===