AI Hints
Elasticsearch · Lesson 40 of 120

Dynamic Mapping

How fields get types.

⏱ 2 min read▶ Video at 36:44🎓 Free
Watch this lesson in the Elasticsearch courseWatch on YouTube ↗Full Elasticsearch course

We never told Elasticsearch what our fields were. It guessed. That guess is called dynamic mapping, and the result is the index's mapping, its list of fields and their types.

  • We never said
  • It guessed
  • The mapping

What did it guess?

GET_mapping shows the mapping. Run it. Price became a float, and in stock a boolean. Added was recognised as a date. And every string, like brand, became text, with a keyword sub field.

Dev Tools Consoletext
GET products/_mapping/field/price,in_stock,added,brand?filter_path=*.mappings.*.mapping
Output
{
  "products": {
    "mappings": {
      "added": {"mapping": {"added": {"type": "date"}}},
      "price": {"mapping": {"price": {"type": "float"}}},
      "in_stock": {"mapping": {"in_stock": {"type": "boolean"}}},
      "brand": {
        "mapping": {
          "brand": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}
Also uses _load
products

How guessing works

JSON true or false becomes boolean. Whole numbers become long, and decimals become float. Strings that look like dates become date. Every other string becomes text, plus a keyword sub field.

keyvalue
true / falseboolean
42long
129.99float
"2025-06-01"date
"Summit"text + keyword

Summary

Dynamic mapping guesses a type for each new field. It's handy for trying things out. Next, why you should usually write the mapping yourself.

Key takeaways
  • Guessed types
  • _mapping
  • text + keyword
Next up: Explicit Mappings — choose the types