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:

  1. you may create field index.
  2. you may change string index supports wildcard search.
  3. 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.


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -