Understanding Elasticsearch Index Mapping & Schema

A schema is a description of one or more fields that describes the document type and how to handle the different fields of a document.

The schema in Elasticsearch is a mapping that describes the the fields in the JSON documents along with their data type, as well as how they should be indexed in the Lucene indexes that lie under the hood. Because of this, in Elasticsearch terms, we usually call this schema a “mapping”.


Mapping Type
Each index has one mapping type which determines how the document will be indexed. A mapping type has:

  1. Meta-fields – Meta-fields are used to customize how a document’s metadata associated is treated. Examples of meta-fields include the document’s _index, _type, _id, and _source fields.
  2. Fields or properties – A mapping type contains a list of fields or properties pertinent to the document.

Fields datatypes
Each field has a data type which can be:

Reference