In this article, we will discuss how to display fields in an Elasticsearch index. This can be useful for understanding the structure of your data, identifying specific fields, and troubleshooting issues. We will cover the following topics:
- Using the
_mappingAPI to retrieve field information - Using the
_searchAPI to display field values - Filtering fields using the
fieldsparameter - Displaying nested fields
1. Using the _mapping API to retrieve field information
The _mapping API allows you to retrieve the mapping definition for an index or multiple indices. This includes information about the fields, their data types, and other properties. To retrieve the mapping for a specific index, use the following request:
GET /<index_name>/_mappingFor example, if you have an index named my_index, you can retrieve its mapping with the following request:
GET /my_index/_mappingThe response will include the mapping definition for the index, which contains information about the fields and their properties.
It is also possible to retrieve the mapping of one specific field. This can be useful if your mapping is quite big and you only want to focus on a specific field. To retrieve the mapping of a specific field, use the following request:
GET /my_index/_mapping/field/my_fieldYou can also retrieve the mappings of several fields by separating their names with commas as in the following request:
GET /my_index/_mapping/field/my_field_1,my_field_2,my_field_32. Using the _search API to display field values
To display the values of fields in an Elasticsearch index, you can use the _search API. By default, the _search API returns the _source field, which contains the original JSON document that was indexed. To display only specific fields, you can use the _source parameter in the search request.
Here’s an example of a search request that returns the values of the title and author fields for documents in the my_index index:
GET /my_index/_search
{
"query": {
"match_all": {}
},
"_source": ["title", "author"]
}In this example, the _source parameter specifies the fields to be returned.
3. Filtering fields using the fields parameter
You can also use the fields parameter to filter the fields returned in the search response. This can be useful if you only need specific fields and want to reduce the size of the response. The fields parameter accepts an array of field names or wildcard patterns.
For example, to return only the title and author fields for documents in the my_index index, you can use the following search request:
GET /my_index/_search
{
"query": {
"match_all": {}
},
"fields": ["title", "author"],
"_source": false
}Note that the _source parameter is set to false in order to not return the source document.
To return all fields with a text data type, you can use a wildcard pattern like this:
GET /my_index/_search
{
"query": {
"match_all": {}
},
"fields": ["*.text"],
"_source": false
}4. Displaying nested fields
If your index contains nested fields, you can use the dot notation to specify the nested field path in the fields parameter. For example, if you have a nested field named address.city, you can include it in the search response like this:
GET /my_index/_search
{
"query": {
"match_all": {}
},
"fields": ["title", "author", "address.city"],
"_source": false
}In this example, the search response will include the values of the title, author, and address.city fields.
Conclusion
In conclusion, displaying fields in an Elasticsearch index can be achieved using the _mapping API to retrieve field information and the _search API to display field values. You can filter the fields returned in the search response either using the _source or fields parameters and display nested fields using the dot notation. These techniques can help you understand the structure of your data, identify specific fields, and troubleshoot issues.
Ready to try this out on your own? Start a free trial.
Want to get Elastic certified? Find out when the next Elasticsearch Engineer training is running!
Related content

December 16, 2025
Reducing Elasticsearch frozen tier costs with Deepfreeze S3 Glacier archival
Learn how to leverage Deepfreeze in Elasticsearch to automate searchable snapshot repository rotation, retaining historical data and aging it into lower cost S3 Glacier tiers after index deletion.

September 22, 2025
Elastic Open Web Crawler as a code
Learn how to use GitHub Actions to manage Elastic Open Crawler configurations, so every time we push changes to the repository, the changes are automatically applied to the deployed instance of the crawler.

August 6, 2025
How to display fields of an Elasticsearch index
Learn how to display fields of an Elasticsearch index using the _mapping and _search APIs, sub-fields, synthetic _source, and runtime fields.

July 14, 2025
Run Elastic Open Crawler in Windows with Docker
Learn how to use Docker to get Open Crawler working in a Windows environment.

June 24, 2025
Ruby scripting in Logstash
Learn about the Logstash Ruby filter plugin for advanced data transformation in your Logstash pipeline.