[MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread Gary Larsen
Hi I'm trying to convert a query to use cts for performance. Is there a cts constructor that I can use the check a variable? Here's a portion of the query: xdmp:directory('/db/netvisn/audit_history/','infinity') /nv:auditHistory

Re: [MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread Michael Blakeley
The quick answer is something like: if ($oc) then () else cts:element-value-query(xs:QName(nv:objectClass), $oc) When $oc is empty, there is no need to include that query term at all. So it can be empty too. However, the long answer is that converting an XPath expression to cts:query won't

Re: [MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread John Snelson
Only add the cts:element-value-query() to your cts:query object if $effect eq 'spec'. In other words, do the comparison outside the cts:query, and build a different cts:query depending on the value of the variables. John On 16/04/12 16:21, Gary Larsen wrote: Hi I’m trying to convert a

Re: [MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread Gary Larsen
: [MarkLogic Dev General] simple cts constructor for variable check The quick answer is something like: if ($oc) then () else cts:element-value-query(xs:QName(nv:objectClass), $oc) When $oc is empty, there is no need to include that query term at all. So it can be empty too. However, the long

Re: [MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread Michael Blakeley
-Original Message- From: general-boun...@developer.marklogic.com [mailto:general-boun...@developer.marklogic.com] On Behalf Of Michael Blakeley Sent: Monday, April 16, 2012 11:53 AM To: MarkLogic Developer Discussion Subject: Re: [MarkLogic Dev General] simple cts constructor

Re: [MarkLogic Dev General] simple cts constructor for variable check

2012-04-16 Thread Gary Larsen
: [MarkLogic Dev General] simple cts constructor for variable check Unless I'm missing something, you shouldn't need the eval. Constructors for cts:query are already fully composable. See the if-then-else expression that I outlined below. -- Mike On 16 Apr 2012, at 09:04 , Gary Larsen wrote: I'm