Hi All,

I'm creating a searchAPI that would perform search on a specific DB and
sends back the xml response.
I have done this using search:search(). The code is working fine.
But when ever I perform a query for huge number of docs[say 90000 docs], it
takes more than 10mnts to return the xml response.

Here is the code,

import module namespace search = "http://marklogic.com/appservices/search";
at "/MarkLogic/appservices/search/search.xqy";

let $searchTerm := "provider:collOne AND country:USA"
let $options    := <options xmlns="http://marklogic.com/appservices/search";>
 <constraint name="country"><range type="xs:string"><element ns=""
name="country"/><attribute ns="" name="countryCode"/></range></constraint>
 <constraint name="provider"><collection prefix="/provider/"/></constraint>
 <return-facets>false</return-facets>
 <extract-metadata><qname elem-ns="" elem-name="name"/><constraint-value
ref="country"/><constraint-value ref="provider"/></extract-metadata>
</options>

let $result       := search:search($searchTerm,$options)
let $totalItems   := data($result//@total)
let $pageSize     := xs:integer(1000)
let $no-of-pages  := xs:integer(math:ceil($totalItems div $pageSize))
let $index        := xs:integer(1)
return
<results>{
for $i in (1 to $no-of-pages)
let $searchResults   := search:search($searchTerm, $options ,$pageSize*($i
- 1)+1, $pageSize)
    for $current in $searchResults//search:result
let $URI     := $current/@uri/string()
return
<doc URI="{$URI}"/>
 }</results>

When I simply return the $result, it is very fast and the time it shows is
<search:total-time>PT0.04323S</search:total-time> for 90000 docs.
But in the return, when I loop through the pages($no-of-pages), it takes a
lot of time.
Please let me know if I'm performing something incorrect here.


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

Reply via email to