In Elasticsearch, mappings define the structure of documents by specifying field names and their data types before any data is added. This helps Elasticsearch know how to store and search the data correctly. For example, if 'age' is defined as an integer, Elasticsearch expects numbers for that field. When a document with the wrong type is indexed, Elasticsearch rejects it to keep data consistent. Mappings also help searches work properly, like comparing numbers for queries. This step-by-step trace shows how mapping is created, documents are indexed, and how mapping enforces rules and guides searching.