regex - cts:value-match on xs:dateTime() type in Marklogic -
i have variable $yearmonth := "2015-02"
have search date on element date xs:datetime
. want use regex expression find files/documents having date "2015-02-??" have path-range-index
enabled on modifiedinfo/date
using following code getting invalid cast
error
let $result := cts:value-match(cts:path-reference("modifiedinfo/date"), xs:datetime("2015-02-??t??:??:??.????"))
i have used following code , getting same error
let $result := cts:value-match(cts:path-reference("modifiedinfo/date"), xs:datetime(xs:date("2015-02-??"),xs:time("??:??:??.????")))
kindly :)
it seems trying use wild card search on path range index has data type xs:datetime().
but, marklogic don't support functionality. there multiple ways handle scenario:
- you may create field index.
- you may change string index supports wildcard search.
you may run workaround support existing system:
for $x in cts:values(cts:path-reference("modifiedinfo/date")) return if(starts-with(xs:string($x), '2015-02')) $x else ()
this query fetch out values lexicon , may filter desired date.