Thanks Michael. It's working now.

Is there any way I can limit the results coming from cts:search() similar
to the $start and $page-length parameters of search:search() ?

Of should I just use the [1 to 100] limiters ? Or is fn:subsequence() a
better choice ?

Regards,
Danny

On Mon, Jun 25, 2012 at 3:28 PM, Michael Blakeley <[email protected]> wrote:

> You are calling cts:search with the XML representation of a query. That
> won't work. Here's why:
>
>
> http://docs.marklogic.com/5.0doc/docapp.xqy#search.xqy?start=1&cat=all&query=search%3Aparse&button=search
>
> search:parse(
> $qtext as xs:string+,
> [$options as element(search:options)?]
> )  as  element()?
>
>
> http://docs.marklogic.com/5.0doc/docapp.xqy#search.xqy?start=1&cat=all&query=cts%3Asearch&button=search
>
> cts:search(
> $expression as node()*,
> $query as cts:query?,
> ...
>
> The search:parse function returns an element in the cts:query schema. The
> cts:search function requires a cts:query item, which is not the same thing.
> You can use the cts:query constructor, or call a function that accepts a
> query element.
>
> Option 1:
>
>    cts:search(collection("trustedPartnerLogs"), cts:query($cts-query))
>
> Note that I also fixed arg1 of your cts:search call. That must be a
> searchable expression - not a cts:query item.
>
> Option 2:
>
>    search:resolve($cts-query)
>
> Option 3:
>
>    search:resolve-nodes($cts-query)
>
> But for the latter two you might have to set that "trustedPartnerLogs"
> collection-query as an additional-query option, to get the results you want.
>
> -- Mike
>
> On 25 Jun 2012, at 11:59 , Danny Sinang wrote:
>
> > Hello,
> >
> > I'm getting the error message below. I've just started using cts:search.
> >
> > Can anyone tell me what it means and how to fix it ?
> >
> > Regards,
> > Danny
> >
> >
> > [1.0-ml] XDMP-NONMIXEDCOMPLEXCONT: fn:data(<cts:and-query
> qtextjoin="AND" strength="20" 
> xmlns:cts="http://marklogic.com/cts";><cts:element-word-query
> qtextpre="trustedPartnerId:" qtextref="c...</cts:and-query>) -- Node has
> complex type with non-mixed complex content
> > Stack trace:
> >
> >
> > at 185
> >
> >
> > 183: let $searchQuery := "( trustedPartnerId:1014582732321112322 ) AND (
> dateRange:2012-06-22T18:00:00.000000-04:00~2012-06-28T23:59:59.000000-04:00
> )"
> >
> > 184: let $cts-query := search:parse($searchQuery, $OPTIONS)
> >
> >
> > 185:
> > return cts:search ( cts:collection-query("trustedPartnerLogs"),
> $cts-query)
> > 186:
> >
> > xdmp:eval("import module namespace search = &quot;
> http://marklogic.com/apps...";, (), <options
> xmlns="xdmp:eval"><database>16371120570641007211</database><root>/opt/MarkLogic/Mo...</options>)
> >
> > $searchQuery := "( trustedPartnerId:1014582732321112322 ) AND (
> dateRange:2012-06..."
> > $cts-query := <cts:and-query qtextjoin="AND" strength="20" xmlns:cts="
> http://marklogic.com/cts";><cts:element-word-query
> qtextpre="trustedPartnerId:" qtextref="c...</cts:and-query>
> >
> > in /eval.xqy at 115
> >
> >
> > 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="trustedPartnerLogId">
> >               <word>
> >               <element ns="" name="trustedPartnerLogId"/>
> >             </word>
> >           </constraint>
> >
> >           <constraint name="module">
> >             <word>
> >               <element ns="" name="module"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="operation">
> >             <word>
> >               <element ns="" name="operation"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="trustedPartnerId">
> >             <word>
> >               <element ns="" name="trustedPartnerId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="customerId">
> >             <word>
> >               <element ns="" name="customerId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="userId">
> >             <range type="xs:long">
> >               <element ns="" name="userId"/>
> >             </range>
> >          </constraint>
> >
> >           <constraint name="groupId">
> >             <word>
> >               <element ns="" name="groupId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="groupCommunityId">
> >             <word>
> >               <element ns="" name="groupCommunityId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="shelfId">
> >             <word>
> >               <element ns="" name="shelfId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="elapsedTime">
> >             <word>
> >               <element ns="" name="elapsedTime"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="count">
> >             <word>
> >               <element ns="" name="count"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="dateCreated">
> >             <word>
> >               <element ns="" name="dateCreated"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="dateModified">
> >             <word>
> >               <element ns="" name="dateModified"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="bookId">
> >             <range type="xs:long">
> >               <element ns="" name="bookId"/>
> >             </range>
> >          </constraint>
> >
> >           <constraint name="sectionId">
> >             <word>
> >               <element ns="" name="sectionId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="paragraphId">
> >             <word>
> >               <element ns="" name="paragraphId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="pageIndex">
> >             <word>
> >               <element ns="" name="pageIndex"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="pageDisplay">
> >             <word>
> >               <element ns="" name="pageDisplay"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="relatedAssetId">
> >             <word>
> >               <element ns="" name="relatedAssetId"/>
> >             </word>
> >          </constraint>
> >
> >           <constraint name="relatedAssetType">
> >             <range collation="http://marklogic.com/collation/";
> type="xs:string">
> >                   <element ns="" name="relatedAssetType"/>
> >              </range>
> >          </constraint>
> >
> >           <constraint name="sessionId">
> >             <range collation="http://marklogic.com/collation/";
> type="xs:string">
> >                   <element ns="" name="sessionId"/>
> >              </range>
> >          </constraint>
> >
> >          <constraint name="taxonomyId">
> >             <range type="xs:long">
> >               <element ns="" name="taxonomyId"/>
> >             </range>
> >          </constraint>
> >
> >          <constraint name="chapterId">
> >             <range type="xs:long">
> >               <element ns="" name="chapterId"/>
> >             </range>
> >          </constraint>
> >
> >          <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 := "( trustedPartnerId:1014582732321112322 ) AND (
> dateRange:2012-06-22T18:00:00.000000-04:00~2012-06-28T23:59:59.000000-04:00
> )"
> > let $cts-query := search:parse($searchQuery, $OPTIONS)
> > return cts:search ( cts:collection-query("trustedPartnerLogs"),
> $cts-query)
> > _______________________________________________
> > General mailing list
> > [email protected]
> > http://community.marklogic.com/mailman/listinfo/general
>
> _______________________________________________
> General mailing list
> [email protected]
> http://community.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
http://community.marklogic.com/mailman/listinfo/general

Reply via email to