I create range-element-index
on property_x
, I set scalar-type
to int
and I want to perform jsonPropertyRangeQuery
on it. But for value that are technically valid it throw error: No decimal element range index for property_x
.
Before I perform jsonPropertyRangeQuery
I check if type of number is in integer range like in this way: xdmp.type(100000025131)
and it return 'integer'
so I think it is correct value because xdmp.type(10000002513100000))
will return 'double'
.
How I can check if the value are able to be use in jsonPropertyRangeQuery
?
Index the value as xs:long
and then you can search without error:
cts.search(cts.jsonPropertyRangeQuery("property_x", "=", 2147483647))
I think there may be some confusion and issues between JavaScript Number
(and in newer version of V8 that MarkLogic isn't yet using, BigInt
) and XML Schema numeric types and ranges for xs:int
and xs:integer
, xs:long
, xs:unsignedLong
, etc.
Although, xdmp.type(100000025131)
returns integer
, and parseInt('100000025131') === 100000025131
returns true
.
xs.int('100000025131')
(max is 2147483647
) throws:
[javascript] XDMP-CAST: function bound ()() -- Invalid cast: "100000025131" cast as xs.int
xs.unsignedInt('100000025131')
(max is 4294967295
) throws:
[javascript] XDMP-CAST: function bound ()() -- Invalid cast: "100000025131" cast as xs.unsignedInt
xs.integer('100000025131')
returns xs.integer
with the value 100000025131
xs.long('100000025131')
returns xs.long
with the value 100000025131
There is an option for indexing as xs:int
, xs:unsignedInt
, xs:long
, and xs:unsignedLong
, but not xs:integer
.
It would be good if you could open a MarkLogic Support ticket and ask for clarification about why xdmp.type(100000025131)
reports integer
, or maybe what documentation there is (or needs to be) to describe how the simple type integer
maps to the schema types xs.integer
, xs.int
, xs.long
, etc.?