The business rules are actually contained in multiple documents. They contain other constraints besides embargo information. The 2-stage query is the approach I was thinking of as well. Perhaps getting all co-occurrences from the rules documents then filtering on the article documents would work.
From: Dave Cassel <[email protected]<mailto:[email protected]>> Date: Monday, October 20, 2014 9:22 AM To: Andrew Wanczowski <[email protected]<mailto:[email protected]>>, John Snelson <[email protected]<mailto:[email protected]>>, "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Element Range Query with DateTime and Durations Drew, if I follow correctly, you're looking at a 2-stage query, where your first stage finds the criteria and the second stage applies those criteria to the real search. Since you have range indexes set up on the relevant data, make sure you're using that to gather the criteria. In other words, rather than: fn:doc("/some/business/rules.xml")/path/to/date-and-duration which requires loading the document, you can probably get that same data from your range indexes: let $date as xs:date := cts:values($date-ref, (), "limit=1", $query-to-find-biz-rules) let $duration as xs:string := cts:values($dur-ref, (), "limit=1", $query-to-find-biz-rules) Sounds like it would be just one document, so it might not make a big difference, but it's one less that would need to be read from disk. -- Dave Cassel Developer Community Manager MarkLogic Corporation<http://www.marklogic.com/> Cell: +1-484-798-8720 From: <Wanczowski>, Andrew <[email protected]<mailto:[email protected]>> Date: Friday, October 17, 2014 at 1:38 PM To: Dave Cassel <[email protected]<mailto:[email protected]>>, John Snelson <[email protected]<mailto:[email protected]>>, "[email protected]<mailto:[email protected]>" <[email protected]<mailto:[email protected]>> Subject: Re: [MarkLogic Dev General] Element Range Query with DateTime and Durations 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
