_type field
Deprecated in 6.0.0.
Each document indexed is associated with a _type and an _id. The _type field is indexed in order to make searching by type name fast.
The value of the _type field is accessible in queries, aggregations, scripts, and when sorting:
# Example documents
PUT my-index-000001/_doc/1?refresh=true
{
"text": "Document with type 'doc'"
}
GET my-index-000001/_search
{
"query": {
"term": {
"_type": "_doc"
}
},
"aggs": {
"types": {
"terms": {
"field": "_type",
"size": 10
}
}
},
"sort": [
{
"_type": {
"order": "desc"
}
}
],
"script_fields": {
"type": {
"script": {
"lang": "painless",
"source": "doc['_type']"
}
}
}
} | Querying on the | |
| Aggregating on the | |
| Sorting on the | |
| Accessing the |
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/7.17/mapping-type-field.html