Ravi
Ravi

Reputation: 1179

Date format in Marklogic for JSON Documents


I am having JSON docs with date in them, and I am trying to create a range index. When I do the ISO8601 format like this

2015-11-02T00:00:00-0600

I get the following error

IndexerEnv::putRangeIndex: XDMP-RANGEINDEX: Range index error: date "2015-11-02T00:00:00-0600": XDMP-LEXVAL: Invalid lexical value "2015-11-02T00:00:00-0600"

I thought it needs to be in UTC time and also needs a 'Z' in the end indicating Zulu time zone, so I forced for testing the time to be as follows

2015-11-02T00:00:00Z

I still get the same error..

IndexerEnv::putRangeIndex: XDMP-RANGEINDEX: Range index error: date "2015-11-02T00:00:00Z": XDMP-LEXVAL: Invalid lexical value "2015-11-02T00:00:00Z"

What is wrong here ? and also another question, does Marklogic understand dates only when we add 'Z' (Zulu timezone) in the date ?

Thanks

Upvotes: 2

Views: 358

Answers (2)

Ravi
Ravi

Reputation: 1179

Thank you all, found my error..

For types other than xs:string, I am not supposed to add the collation parameter to the sort-order.. Changed this to

<sort-order type="xs:dateTime" collation="http://marklogic.com/collation/" direction="ascending">
    <field name="concept_createdDate"/>
</sort-order>

to

<sort-order type="xs:dateTime" direction="ascending">
    <field name="concept_createdDate"/>
</sort-order>

and all worked

Upvotes: 2

prker
prker

Reputation: 504

Is your range index created with the proper data type?

The error tells me you have created a range index of datatype date and your trying to push a dateTime into a date range. Try changing the definition of the range index from type date to type dateTime.

HTH,

Peter

Upvotes: 5

Related Questions