Thanks Colleen, it worked !

On Fri, Oct 19, 2012 at 10:48 AM, Colleen Whitney <
[email protected]> wrote:

> Danny, that's because the options are designed to be used with the
> search:* functions (which are a higher-level API) rather than with
> cts:search. Instead of calling cts:search(), you can call search:resolve()
> (which includes pagination and wrappers just like search:search) or
> search:resolve-nodes() (which just spits out the raw documents, like
> cts:search).   Make sure you pass $OPTIONS into whichever call you decide
> to use.
>
> Colleen Whitney
> MarkLogic Corporation
>
> Phone +1 650 655 2366
> email  [email protected]
> web    www.marklogic.com
>
> This e-mail and any accompanying attachments are confidential. The
> information is intended solely for the use of the individual to whom it is
> addressed. Any review, disclosure, copying, distribution, or use of this
> e-mail communication by others is strictly prohibited. If you are not the
> intended recipient, please notify us immediately by returning this message
> to the sender and delete all copies. Thank you for your cooperation.
>
> ________________________________________
> From: [email protected] [
> [email protected]] On Behalf Of Danny Sinang [
> [email protected]]
> Sent: Friday, October 19, 2012 7:01 AM
> To: general
> Subject: [MarkLogic Dev General] How to make cts:search honor "sort"
>  operator in options
>
> Hello,
>
> cts:search() doesn't seem to be honoring the "sort" operator in my search
> options. When I run the query below, I get results, but they're not sorted
> by "dateCreated" at all.
>
> What am I missing ?
>
> Regards,
> Danny
>
> (:
> ////////////////////////////////////////////////////////////////////////////////////////////////////////////
> :)
>
> import module namespace search = "http://marklogic.com/appservices/search";
> at "/MarkLogic/appservices/search/search.xqy";
>
> declare variable $OPTIONS :=
>
>  <options xmlns="http://marklogic.com/appservices/search";>
>         <search-option>filtered</search-option>
>         <debug>false</debug>
>         <term>
>              <term-option>case-insensitive</term-option>
>              <term-option>wildcarded</term-option>
>         </term>
>         <additional-query>{cts:collection-query("trustedPartnerLogs") }
> </additional-query>
>
>          <constraint name="dateRange">
>          <custom facet="false">
>                 <parse apply="trustedPartnerLog-date-range" ns="
> http://www.xplana.com/date-range-query"; at="/date-range-query.xqy"/>
>           </custom>
>           </constraint>
>
>           <operator name="sort">
>               <state name="date_created-asc">
>                       <sort-order direction="ascending" type="xs:dateTime"
> collation="">
>                         <element ns="" name="dateCreated"/>
>                       </sort-order>
>                       <sort-order>
>                         <score/>
>                       </sort-order>
>               </state>
>               <state name="date_created-desc">
>                       <sort-order direction="descending"
> type="xs:dateTime" collation="">
>                         <element ns="" name="dateCreated"/>
>                       </sort-order>
>                       <sort-order>
>                         <score/>
>                       </sort-order>
>               </state>
>           </operator>
>
>         <return-metrics xmlns="http://marklogic.com/appservices/search
> ">false</return-metrics>
> </options> ;
>
> let $searchQuery :=
> '(dateRange:"2012-10-19T00:00:00.00000-05:00~2012-10-19T23:59:59.99999-05:00")
> AND (sort:date_created-desc)'
> let $cts-query := search:parse($searchQuery, $OPTIONS)
> let $count :=
> xdmp:estimate(cts:search(fn:collection("trustedPartnerLogs"),
> cts:query($cts-query)))
> let $searchResults := cts:search(fn:collection("trustedPartnerLogs"),
> cts:query($cts-query))
> return $searchResults
> _______________________________________________
> 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