I am using the cts library to generate "and-queries" that join dateTime
range queries. The data I'm searching has dates in the format "YYYY-MM-DD
hh:mm:ss" (note the space). I created a dateTime range index AFTER the docs
were loaded. When I run a query with search criteria including a dateTime
specified using what appears to be the required format for dateTimes, e.g.
"2009-12-15T11:52:00", I get an error that seems to result from the invalid
date formats in docs already in the DB (i.e. the error complains about
documents in the DB, not about the query I'm running).
If I try to use the same format, querying using a <date string> with a space
instead of a 'T', as in the loaded docs, I get error "invalid cast: <date
string> cast as xs:dateTime" -- this time the error is complaining about my
query. Not surprising since (I think) the 'T' is required for ML dateTimes.
(Question #1: dateTime formats) Is it really necessary that the data for
which dateTime range indexes are created in the DB be in the
"YYYY-MM-DDThh:mm:ss" format (where the 'T' is literal)? What do others do
to get around this restriction?
Next, I copied a document from the collection I was using, changed dateTime
formats to include the 'T', loaded the document, and re-indexed the
database. Now, when I run the query that previously resulted in an error
using this modified document as the target, the document is returned as
satisfying the query.
(Question #2: and-query() problem -- see code below) However, if I run the
same query (q1) but join it in a cts:and-query() with any other query that
also is satisfied by the document when the query is run by itself (q2), I
get no results. So it seems to be a case where cts:and-query() does NOT
return the intersection of its constituent queries (as it is defined to
do). What might cause that?
==== code... ====
(: q1: RETURNS THE TEST DOCUMENT: :)
cts:search(fn:doc("my-test-doc.xml"),
cts:and-query((
cts:element-query(fn:QName("http://ns", "L1"),
cts:element-query(fn:QName("http://ns", "L2"),
cts:element-query(fn:QName("http://ns", "L3"),
cts:element-range-query(fn:QName("http://ns",
"StartDate"), ">=", xs:dateTime("1900-01-01T00:00:00")))))
))
)
(: q2: RETURNS THE TEST DOCUMENT: :)
cts:search(fn:doc("my-test-doc.xml"),
cts:and-query((
cts:element-query(fn:QName("http://ns", "L1"),
cts:element-query(fn:QName("http://ns", "L2"),
cts:element-query(fn:QName("http://ns", "L3"),
cts:element-value-query(fn:QName("http://ns", "ID"),
"X032923492"))))
))
)
(: Q = cts:and-query(q1, q2): RETURNS NO RESULTS: :)
cts:search(fn:doc("my-test-doc.xml"),
cts:and-query((
cts:element-query(fn:QName("http://ns", "L1"),
cts:element-query(fn:QName("http://ns", "L2"),
cts:element-query(fn:QName("http://ns", "L3"),
cts:element-range-query(fn:QName("http://ns",
"StartDate"), ">=", xs:dateTime("1900-01-01T00:00:00"))))),
cts:element-query(fn:QName("http://ns", "L1"),
cts:element-query(fn:QName("http://ns", "L2"),
cts:element-query(fn:QName("http://ns", "L3"),
cts:element-value-query(fn:QName("http://ns", "ID"),
"X032923492"))))
))
)
====
Thanks,
Karl
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general