How it works...

The mapping is stored at the cluster level in Elasticsearch. The call checks both the index and type existence, and then it returns the stored mapping.

The returned mapping is in a reduced form, which means that the default values for a field are not returned. T o reduce network and memory consumption, Elasticsearch returns non-default values.

Retrieving a mapping is very useful for several purposes:
  • Debugging template level mapping
  • Checking if implicit mapping was derived correctly by guessing fields
  • Retrieving the mapping metadata, which can be used to store type-related information
  • Simply checking if the mapping is correct
If you need to fetch several mappings, it is better to do it at the index level or the cluster level to reduce the numbers of API calls.