Thanks.  I haven't worked with the map function yet.  I was trying to use 
distinct-values in the for loop, but get an error that my value isn't a node 
(which is true)

for $audience in xs:string(fn:distinct-values($these-docs//ec:audience))
order by $audience
return $audience/fn:string()

>> [1.0-ml] XDMP-NOTANODE: (err:XPTY0019) $audience/fn:string(.) -- 
>> "Automotive" is not a node

How would I map this a cts search?

xquery version "1.0-ml"; 
declare namespace ec = "http://www.alm.com/event-calendar";;
let $directory:="/data-sources/editorial-calendar/"
let $these-docs:= 
cts:search(
  xdmp:directory($directory),                                        
  cts:and-query((
    cts:element-attribute-range-query(xs:QName("ec:MaterialsDueDate"), 
xs:QName("date"), ">=", xs:date(fn:current-date()) ),
    cts:element-query(xs:QName("ec:approval_status"),cts:word-query("true"))
  ))
) 

for $audience in $these-docs//ec:audience
order by $audience
 return $audience/fn:string()



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Christopher Hamlin
Sent: Thursday, July 30, 2015 12:46 PM
To: MarkLogic Developer Discussion <[email protected]>
Subject: Re: [MarkLogic Dev General] Sorting and De-duping

Just to look ahead a little to that next question: fn:distinct-values says "The 
order in which the sequence of values is returned is implementation dependent."

One way to maintain order is to go through your values in order, only pass the 
ones that haven't been seen.  map:map is useful for that kind of side effect.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general



_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to