What is a mapping in Elasticsearch?

Answer

A mapping in Elasticsearch defines the schema for an index — it specifies how documents and their fields are stored and indexed. The mapping defines each field's data type (text, keyword, integer, date, boolean, geo_point, etc.) and indexing options (whether to store, analyze, or index the field). Unlike a relational database schema, Elasticsearch mapping is optional — if you do not define one, it uses dynamic mapping to automatically infer types from the first document indexed. However, auto-inferred mappings are often suboptimal, so explicitly defining mappings is strongly recommended in production.