Core datatypes

The core datatypes supported by Elasticsearch are as follows:

  • String datatypes:
    • text: The text datatype is useful for supporting full-text search for fields that contain a description or lengthy text values. These fields are analyzed before indexing to support full-text search.
    • keyword: The keyword type enables analytics on string fields. Fields of this type support sorting, filtering, and aggregations.
  • Numeric datatypes
    • byte, short, integer, and long: Signed integers with 8-bit, 16-bit, 32-bit, and 64-bit precision, respectively
    • float and double: IEEE 754 floating-point numbers with single-precision 32-bit and double-precision 64-bit representations
    • half_floatIEEE 754 floating-point number with half-precision 16-bit representation
    • scaled_float: Floating-point number backed by a long and fixed scaling factor
  • Date datatype:
    • date: Date with an optional timestamp component that's capable of storing precision timestamps down to the millisecond
  • Boolean datatype:
    • boolean: The boolean datatype that is common in all programming languages
  • Binary datatype:
    • binary: Allows you to store arbitrary binary values after performing Base64 encoding
  • Range datatypes
    • integer_range, float_range, long_range, double_range, and date_range: Defines ranges of integers, floats, longs, and more
scaled_float  is a very useful datatype for storing something such as price, which always has a precision of a limited number of decimal places. Price can be stored with a scaling factor of 100, so a price of $10.98 would be internally stored as 1,098 cents and can be treated as an integer. Internally, scaled_float is much more storage efficient since integers can be compressed much better.