Numeric field types

The following table lists all numeric field types that OpenSearch supports.

Field data typeDescription
byteA signed 8-bit integer. Minimum is −128. Maximum is 127.
doubleA double-precision 64-bit IEEE 754 floating-point value. Minimum magnitude is 2−1074 . Maximum magnitude is (2 − 2−52) · 21023. The number of significant bits is 53. The number of significant digits is 15.95.
floatA single-precision 32-bit IEEE 754 floating-point value. Minimum magnitude is 2−149 . Maximum magnitude is (2 − 2−23) · 2127. The number of significant bits is 24. The number of significant digits is 7.22.
half_floatA half-precision 16-bit IEEE 754 floating-point value. Minimum magnitude is 2−24 . Maximum magnitude is 65504. The number of significant bits is 11. The number of significant digits is 3.31.
integerA signed 32-bit integer. Minimum is −231. Maximum is 231 − 1.
longA signed 64-bit integer. Minimum is −263. Maximum is 263 − 1.
unsigned_longAn unsigned 64-bit integer. Minimum is 0. Maximum is 264 − 1.
shortA signed 16-bit integer. Minimum is −215. Maximum is 215 − 1.
scaled_floatA floating-point value that is multiplied by the double scale factor and stored as a long value.

Integer, long, float, and double field types have corresponding range field types.

If your numeric field contains an identifier such as an ID, you can map this field as a keyword to optimize for faster term-level queries. If you need to use range queries on this field, you can map this field as a numeric field type in addition to a keyword field type.

Example

Create a mapping where integer_value is an integer field:

  1. PUT testindex
  2. {
  3. "mappings" : {
  4. "properties" : {
  5. "integer_value" : {
  6. "type" : "integer"
  7. }
  8. }
  9. }
  10. }

copy

Index a document with an integer value:

  1. PUT testindex/_doc/1
  2. {
  3. "integer_value" : 123
  4. }

copy

Scaled float field type

A scaled float field type is a floating-point value that is multiplied by the scale factor and stored as a long value. It takes all optional parameters taken by number field types, plus an additional scaling_factor parameter. The scale factor is required when creating a scaled float.

Scaled floats are useful for saving disk space. Larger scaling_factor values lead to better accuracy but higher space overhead.

Scaled float example

Create a mapping where scaled is a scaled_float field:

  1. PUT testindex
  2. {
  3. "mappings" : {
  4. "properties" : {
  5. "scaled" : {
  6. "type" : "scaled_float",
  7. "scaling_factor" : 10
  8. }
  9. }
  10. }
  11. }

copy

Index a document with a scaled_float value:

  1. PUT testindex/_doc/1
  2. {
  3. "scaled" : 2.3
  4. }

copy

The scaled value will be stored as 23.

Parameters

The following table lists the parameters accepted by numeric field types. All parameters are optional.

ParameterDescription
boostA floating-point value that specifies the weight of this field toward the relevance score. Values above 1.0 increase the field’s relevance. Values between 0.0 and 1.0 decrease the field’s relevance. Default is 1.0.
coerceA Boolean value that signals to truncate decimals for integer values and to convert strings to numeric values. Default is true.
doc_valuesA Boolean value that specifies whether the field should be stored on disk so that it can be used for aggregations, sorting, or scripting. Default is true.
ignore_malformedA Boolean value that specifies to ignore malformed values and not to throw an exception. Default is false.
indexA Boolean value that specifies whether the field should be searchable. Default is true.
metaAccepts metadata for this field.
null_valueA value to be used in place of null. Must be of the same type as the field. If this parameter is not specified, the field is treated as missing when its value is null. Default is null.
storeA Boolean value that specifies whether the field value should be stored and can be retrieved separately from the _source field. Default is false.

Scaled float has an additional required parameter: scaling_factor.

ParameterDescription
scaling_factorA double value that is multiplied by the field value and rounded to the nearest long. Required.