Once again I am bailed out with everyone's help in this mail list.

Thanks!
gary

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Michael
Blakeley
Sent: Wednesday, August 31, 2011 5:34 PM
To: General MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] determine the first result in an
orderby

If the $p is ancillary to the results, why not just use one of these?

(
  for  $x at $p in cts:search(doc(), $cq2, 'unfiltered')/content/lookupInfo
  order by string-length($x/searchPathEnc) descending
  return <x><pos>{$p}</pos>{$x/searchPathEnc}</x>
)[1]

Or

subsequence(
  for  $x at $p in cts:search(doc(), $cq2, 'unfiltered')/content/lookupInfo
  order by string-length($x/searchPathEnc) descending
  return <x><pos>{$p}</pos>{$x/searchPathEnc}</x>,
  1, 1)

-- Mike

On 31 Aug 2011, at 13:01 , Gary Larsen wrote:

> I'm also struggling with an order by problem today.  What I need is the
first of the sorted results from this query:
>  
> for  $x at $p in cts:search(doc(), $cq2,
'unfiltered')/content/lookupInfoorder by string-length($x/searchPathEnc)
descending return
> <x><pos>{$p}</pos>{$x/searchPathEnc}</x> 
> 
> <x>
>     <pos>2</pos>
>
<searchPathEnc>%2Fcontent%2Fpackage%5B%40name%3D%27Demo%27%5D</searchPathEnc
>
> </x>
> <x>
>     <pos>1</pos>
>     <searchPathEnc>%2Fcontent</searchPathEnc>
> </x>
> 
> I would expect that the first result would have a position value of 1 but
that's not the case.  Is there a way to determine (or get directly) the
first of the ordered results?
>  
> Sorry if this is just my lack of XQuery knowledge,
> gary
>  
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

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

Reply via email to