Skip to content

[DOCS][ESQL] Document _source metadata field#105237

Merged
leemthompo merged 4 commits intoelastic:mainfrom
leemthompo:esql-source-metadata-doc
Feb 7, 2024
Merged

[DOCS][ESQL] Document _source metadata field#105237
leemthompo merged 4 commits intoelastic:mainfrom
leemthompo:esql-source-metadata-doc

Conversation

@leemthompo
Copy link
Copy Markdown
Member

Closes #103872

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 7, 2024

Documentation preview:

@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-docs (Team:Docs)

@elasticsearchmachine elasticsearchmachine added Team:Docs Meta label for docs team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Feb 7, 2024
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

Copy link
Copy Markdown
Contributor

@alex-spies alex-spies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @leemthompo ! I have only minor remarks.

To enable the access to these fields, the <<esql-from,`FROM`>> source command needs
to be provided with a dedicated directive:
* <<mapping-source-field,`_source`>>: the original JSON document body
that was passed at index time. The field is loaded as a special `_source`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is technically incorrect in case of "_source": {"mode": "synthetic"}; since we don't store the original JSON document, the returned _source will generally have re-ordered fields, or timestamps like 2023-01-01 will be expanded to 2023-01-01T00:00:00.000Z.

Maybe like this:

Suggested change
that was passed at index time. The field is loaded as a special `_source`
that was passed at index time (or a reconstructed version thereof in case synthetic source is enabled). The field is loaded as a special `_source`

with a link to https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-source-field.html#synthetic-source ?

Synthetic source is not yet GA, so I wonder if we need to include it here for completeness' sake or not.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes if we want to mention synthetic-source we should have a link

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in f53d4bf

to be provided with a dedicated directive:
* <<mapping-source-field,`_source`>>: the original JSON document body
that was passed at index time. The field is loaded as a special `_source`
type. This field is not supported by functions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Funnily enough, it is currently supported by count, but not count_distinct. I opened #105240

Otherwise, this statement appears to be correct; I'd leave it as-is for now.

[source,esql]
----
FROM index [METADATA _index, _id]
FROM index [METADATA _index, _id, _source]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that a syntax change is coming in #105221, which may require a follow-up PR.

@leemthompo leemthompo merged commit fb743da into elastic:main Feb 7, 2024
@leemthompo leemthompo deleted the esql-source-metadata-doc branch February 7, 2024 14:57
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

💚 Backport successful

Status Branch Result
8.12

leemthompo added a commit to leemthompo/elasticsearch that referenced this pull request Feb 7, 2024
* [DOCS][ESQL] Document _source metadata field

* 🚗 Minor copyedit to entire page
elasticsearchmachine pushed a commit that referenced this pull request Feb 7, 2024
* [DOCS][ESQL] Document _source metadata field

* 🚗 Minor copyedit to entire page
@leemthompo
Copy link
Copy Markdown
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL >docs General docs changes Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) Team:Docs Meta label for docs team v8.12.2 v8.13.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESQL: DOCument _source metadata field

3 participants