Hi Eric, I get the search results as below (return $searchResults)
<search:response snippet-format="snippet" total="69" start="1" page-length="10" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="" xmlns:search="http://marklogic.com/appservices/search"> <search:result ...... ........ ........ </search:response> Why is that, it is not returning any value when I perform the below return statement ? return $searchResults//search:response/@total/string() Thanks, Sini On Thu, Mar 21, 2013 at 8:33 PM, Erik Hennum <[email protected]>wrote: > Hi, Sini: > > I neglected to mention a couple of points that might be useful. > > The search response has a total attribute that provides the estimate. > > I assume you are writing XQuery in QueryConsole to prototype some client > code. If that's not the case, you might consider stating the query in XML > rather than in JSON to skip the transform step and thus simplify the > processing. > > > Erik Hennum > ------------------------------ > *From:* [email protected] [ > [email protected]] on behalf of Erik Hennum [ > [email protected]] > *Sent:* Thursday, March 21, 2013 7:37 AM > *To:* MarkLogic Developer Discussion > *Subject:* Re: [MarkLogic Dev General] search:estimate > > Hi, Sini: > > If you need to return all results, you could increase the page length in > the query options to the largest number of results that you would > reasonably want to return. > > > Hoping that helps, > > > Erik Hennum > > ------------------------------ > *From:* [email protected] [ > [email protected]] on behalf of sini narayanan [ > [email protected]] > *Sent:* Thursday, March 21, 2013 7:20 AM > *To:* MarkLogic Developer Discussion > *Subject:* [MarkLogic Dev General] search:estimate > > Hi All, > > I'm trying to get the total number of results returned after executing a > query. > > The below code is working fine, but returns only 10 results (default > page-length). But the total result count is 69. > > (:All the import statements are provided :) > let $exportQuery := > '{"query":{"and-query":{"queries":[{"range-constraint-query":{"constraint-name":"city","value":["Paris > 01"]}}]}}}' > let $options := xdmp:http-get("http://localhost:6024/v1/config/query/all", > <options xmlns="xdmp:http"> > <authentication method="digest"> > <username>admin</username> > <password>admin</password> > </authentication> > <format xmlns="xdmp:document-get">xml</format> > </options>)//search:options > let $query := > json:transform-from-json($exportQuery,$sut:json-config-query) > let $searchResults := search:resolve($query, $options) > return $searchResults > > I was trying to use the "search:estimate" command to get the total count > of results. But when I execute the command > let $totalItems := search:estimate($query) (:$query being the same as > above code:) > it is throwing some exception. > > How do I use search:parse on this $query, which is transformed from json? > > I need the $totalItems to return 69. > > Any help on this regard would be helpful. > > Thanks, > Sini > > _______________________________________________ > General mailing list > [email protected] > http://developer.marklogic.com/mailman/listinfo/general > >
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
