[MarkLogic Dev General] Range query: strange behavior
Michael Blakeley
michael.blakeley at marklogic.com
Mon Dec 7 13:09:44 PST 2009
Does your database contains one or more empty DateOfBirth elements?
The server won't let you insert empty elements on which a date range
index already exists. But if you insert some empty DateOfBirth elements,
and then create the range index, you will see errors like the one you
have described.
You should be able to fix this by writing an XPath that selects the
empty DateOfBirth elements, and then use xdmp:node-delete() to remove
each one.
-- Mike
On 2009-12-07 12:24, Karl Erisman wrote:
> My question involves strange behavior when using the cts:query
> constructors and range indexes/queries.
>
> The following range query fails:
>
> (: (1) :)
> cts:search( collection(), cts:and-query((
> cts:element-range-query(fn:QName("http://my-namespace",
> "DateOfBirth"),">", xs:date("1975-01-01") ),
> cts:query(())
> )))
>
> The error string is: "Invalid cast: xs:untypedAtomic("") cast as xs:date".
> That sounds like there's an error with the FIRST nested query involving the
> date cast.
>
> However, merely adding a nested query makes the search successful. Note that
> the FIRST nested query does not change:
>
> (: (2) :)
> cts:search(collection(), cts:and-query((
> cts:element-range-query(fn:QName("http://my-namespace",
> "DateOfBirth"),">", xs:date("1975-01-01") ),
> cts:query(()),
> cts:element-value-query(fn:QName("http://my-namespace",
> "PatientFirstName"), "*")
> )))
>
> Since (2) works, I must have properly created the range element index
> and the range query must be correct. What is wrong?
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
More information about the General
mailing list