You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{esql} can access <<mapping-fields, metadata fields>>. The currently
9
-
supported ones are:
7
+
{esql} can access <<mapping-fields, metadata fields>>.
10
8
11
-
* <<mapping-index-field,`_index`>>: the index to which the document belongs.
12
-
The field is of the type <<keyword, keyword>>.
9
+
To access these fields, use the `METADATA` directive with the <<esql-from,`FROM`>> source command. For example:
13
10
14
-
* <<mapping-id-field,`_id`>>: the source document's ID. The field is of the
15
-
type <<keyword, keyword>>.
11
+
[source,esql]
12
+
----
13
+
FROM index METADATA _index, _id
14
+
----
16
15
17
-
* `_version`: the source document's version. The field is of the type
18
-
<<number,long>>.
16
+
[[esql-metadata-fields-available]]
17
+
==== Available metadata fields
19
18
20
-
* <<mapping-ignored-field,`_ignored`>>: the ignored source document fields. The field is of the type
21
-
<<keyword,keyword>>.
19
+
The following metadata fields are available in {esql}:
22
20
23
-
* `_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>>.
21
+
[cols="1,1,3"]
22
+
|===
23
+
|Metadata field |Type |Description
24
24
25
-
To enable the access to these fields, the <<esql-from,`FROM`>> source command needs
26
-
to be provided with a dedicated directive:
25
+
|<<mapping-id-field,`_id`>>
26
+
|<<keyword, keyword>>
27
+
|Unique document ID.
27
28
28
-
[source,esql]
29
-
----
30
-
FROM index METADATA _index, _id
31
-
----
29
+
|<<mapping-ignored-field,`_ignored`>>
30
+
|<<keyword, keyword>>
31
+
|Names every field in a document that was ignored when the document was indexed.
32
+
33
+
|<<mapping-index-field,`_index`>>
34
+
|<<keyword, keyword>>
35
+
|Index name.
36
+
37
+
|`_index_mode`
38
+
|<<keyword, keyword>>
39
+
|<<index-mode-setting,Index mode>>. For example: `standard`, `lookup`, or `logsdb`.
40
+
41
+
|`_score`
42
+
|<<number,`float`>>
43
+
|Query relevance score (when enabled). Scores are updated when using <<esql-search-functions,full text search functions>>.
32
44
33
-
Metadata fields are only available if the source of the data is an index.
34
-
Consequently, `FROM` is the only source commands that supports the `METADATA`
35
-
directive.
45
+
|<<mapping-source-field,`_source`>>
46
+
|Special `_source` type
47
+
|Original JSON document body passed at index time (or a reconstructed version if <<synthetic-source,synthetic `_source`>> is enabled).
36
48
37
-
Once enabled, these fields will be available to subsequent processing commands, just
38
-
like other index fields:
49
+
|`_version`
50
+
|<<number,`long`>>
51
+
|Document version number
52
+
|===
53
+
54
+
[[esql-metadata-fields-usage]]
55
+
==== Usage and limitations
56
+
57
+
- Metadata fields are only available when the data source is an index
58
+
- The `_source` type is not supported by functions
59
+
- Only the `FROM` command supports the `METADATA` directive
60
+
- Once enabled, metadata fields work like regular index fields
61
+
62
+
[[esql-metadata-fields-examples]]
63
+
==== Examples
64
+
65
+
[[esql-metadata-fields-examples-basic]]
66
+
===== Basic metadata usage
67
+
68
+
Once enabled, metadata fields are available to subsequent processing commands, just like other index fields:
0 commit comments