What is dynamic mapping in Elasticsearch?

Answer

Dynamic mapping is Elasticsearch's automatic type detection feature. When you index a document that contains a field not yet defined in the mapping, Elasticsearch infers the appropriate data type and adds it to the mapping automatically. For example, a JSON boolean becomes a boolean field, a number becomes long or float, and a string that looks like a date becomes date. Importantly, string fields that do not match a date pattern are mapped as both text (for full-text search) and keyword (for exact match/sorting/aggregations) by default. Dynamic mapping is convenient but can cause unexpected mappings — always validate in production.