AI Hints
Home›Elasticsearch Tutorial›Field Types in Depth
Elasticsearch · Lesson 44 of 120

Numbers, Dates, Booleans

The other types.

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

Numbers, dates and booleans look simple, but a few details matter. Pick the right size of number, and tell Elasticsearch how your dates are written.

  • Pick the number size
  • Date formats
  • Booleans

A custom date format

Our supplier sends dates like fourteen slash eleven slash twenty twenty six. The format tells Elasticsearch how to read them. Then a range query on the date works normally. Run it.

Dev Tools Consoletext
PUT shipments
{ "mappings": { "properties": {
    "arrived": { "type": "date", "format": "dd/MM/yyyy" },
    "boxes":   { "type": "short" } } } }

POST shipments/_doc?refresh=true&filter_path=result
{ "arrived": "14/11/2026", "boxes": 12 }

GET shipments/_count?filter_path=count
{ "query": { "range": { "arrived": { "gte": "01/11/2026" } } } }
Output
# PUT shipments 200 OK
{
  "acknowledged": true,
  "shards_acknowledged": true,
  "index": "shipments"
}

# POST shipments/_doc 201 Created
{"result": "created"}

# GET shipments/_count 200 OK
{"count": 1}

Choosing types

Use integer or long for counts. Float or scaled float for prices. Dates are stored as milliseconds, but you can read and write many formats. And booleans accept true and false, or the strings true and false.

keyvalue
Countsinteger, long, short
Moneyscaled_float
Datesformat: dd/MM/yyyy
Booleanstrue / false

Summary

Pick a number type that fits, set a date format if yours isn't standard, and booleans just work. Next, objects and arrays.

Key takeaways
  • short, long
  • scaled_float
  • date format
Next up: Objects and Arrays — JSON inside JSON