mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-25 23:57:20 -04:00
* Clarify that field data cache includes global ordinals * Describe that the cache should be cleared once the limit is reached * Clarify that the `_id` field does not supported aggregations anymore * Fold the `fielddata` mapping parameter page into the `text field docs * Improve cross-linking
46 lines
1.3 KiB
Text
46 lines
1.3 KiB
Text
[[mapping-id-field]]
|
|
=== `_id` field
|
|
|
|
Each document has an `_id` that uniquely identifies it, which is indexed
|
|
so that documents can be looked up either with the <<docs-get,GET API>> or the
|
|
<<query-dsl-ids-query,`ids` query>>. The `_id` can either be assigned at
|
|
indexing time, or a unique `_id` can be generated by {es}. This field is not
|
|
configurable in the mappings.
|
|
|
|
The value of the `_id` field is accessible in queries such as `term`,
|
|
`terms`, `match`, and `query_string`.
|
|
|
|
[source,console]
|
|
--------------------------
|
|
# Example documents
|
|
PUT my-index-000001/_doc/1
|
|
{
|
|
"text": "Document with ID 1"
|
|
}
|
|
|
|
PUT my-index-000001/_doc/2?refresh=true
|
|
{
|
|
"text": "Document with ID 2"
|
|
}
|
|
|
|
GET my-index-000001/_search
|
|
{
|
|
"query": {
|
|
"terms": {
|
|
"_id": [ "1", "2" ] <1>
|
|
}
|
|
}
|
|
}
|
|
--------------------------
|
|
|
|
<1> Querying on the `_id` field (also see the <<query-dsl-ids-query,`ids` query>>)
|
|
|
|
The `_id` field is restricted from use in aggregations, sorting, and scripting.
|
|
In case sorting or aggregating on the `_id` field is required, it is advised to
|
|
duplicate the content of the `_id` field into another field that has
|
|
`doc_values` enabled.
|
|
|
|
[NOTE]
|
|
==================================================
|
|
`_id` is limited to 512 bytes in size and larger values will be rejected.
|
|
==================================================
|