Danny, Thanks for replying. I am up to date (4.1-3). I can't imagine how a difference in a particular document could cause this particular result. If the problem were simply an issue of validating that a certain query returns a certain result, then we would want to know how the query performs against varying document content. But in this case, I have two queries such that all documents satisfied by the first must logically be satisfied by the second.
That said, I did try your test and got the expected result. Then I repeated it using a named namespace (and changed the indexes to match) -- same result. However, by the reasoning in my first paragraph, I don't see how differing content could cause the behavior I described (and, though my document obviously has differences to the test case you described, I wouldn't know where to begin in identifying any "significant" differences). Do you agree with my reasoning? Any other ideas? Thanks, Karl On Fri, Jan 8, 2010 at 7:54 PM, Danny Sokolsky <[email protected]> wrote: > Hi Karl, > > At least with a simple document, this works for me. Maybe there is something > about the data in that document that is causing this? Are you using a recent > version of MarkLogic Server? Here is what I tried: > > 1) Create dateTime range indexes for AdmissionDate and DischargeDate (I made > these in no namespace and made my document and query in no namespace as well). > 2) Create the following document: > > xquery version "1.0-ml"; > xdmp:document-insert("/karl.xml", > <Encounter> > <AdmissionDate>2008-10-14T10:43:00</AdmissionDate> > <DischargeDate>2008-10-17T10:43:00</DischargeDate> > </Encounter>) > > 3) Run the following query: > > xquery version "1.0-ml"; > cts:search( doc(), > cts:and-query( > cts:element-query(fn:QName("", "Encounter"), > cts:and-query(( > cts:element-range-query(fn:QName("", > "AdmissionDate"), ">=", xs:dateTime("2008-10-14T10:43:00"), (), 1), > cts:element-range-query(fn:QName("", > "DischargeDate"), "<=", xs:dateTime("2008-10-17T10:43:00"), (), 1) > )))) > ) > > It returned the document as expected. > > Maybe there is something different about the data in your document? > > -Danny > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Karl Erisman > Sent: Friday, January 08, 2010 2:31 PM > To: General Mark Logic Developer Discussion > Subject: [MarkLogic Dev General] Bizarre cts:query behavior > > I noticed a cts:query not doing what I expected. To track down the > problem, I simplified it to the most minimal form that still exhibits > the problem. While experimenting with the query, I found two > nearly-identical queries that together appear to contradict a simple > logical property... > > There is a certain document in my database that satisfies the following query: > ======= > let $d := cts:search( doc(), > cts:and-query( > cts:element-query(fn:QName("my-ns", "Encounter"), > cts:and-query(( > cts:element-range-query(fn:QName("my-ns", > "AdmissionDate"), ">=", xs:dateTime("2008-10-14T10:43:00"), (), 1), > cts:element-range-query(fn:QName("my-ns", > "DischargeDate"), "=", xs:dateTime("2008-10-17T10:43:00"), (), 1) > )))) > ) > return for $i in $d > return $i > ======= > > ...but if I change only the operator in the second line of the nested > and-query as follows: > ======= > cts:element-range-query(fn:QName("my-ns", "DischargeDate"), "<=", > xs:dateTime("2008-10-17T10:43:00"), (), 1) > ======= > > ...there are no results. > > So nothing changed except that instead of requiring that DischargeDate > be EQUAL TO a certain date, I require that it be LESS THAN OR EQUAL TO > that same date. In the first case, the document is matched, but not > in the second case. > > Note that I have a dateTime range index on DischargeDate (obviously, > or I'd get an exception in either case). The document has > DischargeDate equal to the date I am using here, so <=, =, and >= > operators should all result in a match. > > What's going on? I don't often entertain the idea that there may be a > bug in MarkLogic, but this one makes me wonder. > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ > General mailing list > [email protected] > http://xqzone.com/mailman/listinfo/general > _______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
