Skip to content

Casting Values

Edit page

Cast allows explicit conversion from one data type to another as long as types are compatible.

SEARCH /bank/
{
"_query": {
"balance" : {
"_integer": 2221.82
}
}
}

In the above example cast 2221.46 to integer, which later is internally converted to 2221.0 (as the “balance” field is a float).

The following example will convert the integer 84535 to text "84535":

SEARCH /bank/
{
"_query": {
"contact.postcode" : {
"_text": 84535
}
}
}
TypesCompatible Types
_integer_positive, _float, _boolean, _text
_positive_integer, _float, _boolean, _text
_float_integer, _positive, _boolean, _text
_boolean_integer, _positive, _float, _text
_text_integer, _positive, _float, _boolean, _date, _time, _keyword and objects
_date _time _geospatial _uuid_text