Hi John and Dave, In testing the provided example worked well:
xquery version "1.0-ml"; declare namespace html = "http://www.w3.org/1999/xhtml"; let $results := cts:search( fn:doc(), cts:element-range-query(xs:QName("publishedDate"), "<=", fn:current-date() - xs:dayTimeDuration("P90D")) )[1 to 10] let $onSaleDates := ( xs:date("2014-07-18"), (: July 18 published date :) xs:date("2014-07-19"), (: July 19 published date :) xs:date("2014-07-20") (: July 20 published date :) ) let $testCases := for $onSaleDate in $onSaleDates return ( $onSaleDate, ($onSaleDate <= fn:current-date() - xs:dayTimeDuration("P90D")) ) return $testCases I am trying to solve a larger problem of filtering over larger datasets (5M+ documents) where the durations are variables that come from one set of documents (business rules) and filter search of other documents (articles). Basically it is to filter out content with various embargo durations. The "business rules"only state duration after published date not the actual dates the embargo ends. Would you say there is anything to watch out with from a performance standpoint? I have range indexes set up on all the fields that require calculations. Thanks Drew From: Dave Cassel <[email protected]<mailto:[email protected]>> Date: Friday, October 17, 2014 12:09 PM To: Andrew Wanczowski <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Element Range Query with DateTime and Durations Drew, I wasn't sure how familiar you are with durations, so in case John's answer didn't give you what you need -- cts:element-range-query( xs:QName("date"), ">", fn:current-date() - xs:dayTimeDuration("P90D") ) -- Dave Cassel Developer Community Manager MarkLogic Corporation<http://www.marklogic.com/> Cell: +1-484-798-8720 From: <Wanczowski>, Andrew <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Friday, October 17, 2014 at 6:42 AM To: "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Element Range Query with DateTime and Durations Thanks John. I'll give that a shot. On 10/17/14 9:35 AM, "John Snelson" <[email protected]<mailto:[email protected]>> wrote: Work out a dateTime 90 days before the current dateTime, and query for articles with a published dateTime before that dateTime. John On 17/10/14 14:26, Wanczowski, Andrew wrote: Hi All, Is possible to do a dateTime range query based on the elements value plus or minus a xs:dayTimeDuration. For example I want to find all articles that are 90 days passed the published date. The documentation (http://docs.marklogic.com/cts:element-range-query) gives a few examples of date queriers but they all have a supplied dateTime. Thanks Drew -- John Snelson, Lead Engineer http://twitter.com/jpcs MarkLogic Corporation http://www.marklogic.com _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected]<mailto:[email protected]> http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
