I have a search function that calls other search functions that are independent 
of each other. The master search function takes the results of these sub-search 
functions and compiles and processes them according to some rules. 

I would like the sub-search functions to all execute in parallel at the same 
time to reduce the response time of the call to the master search function.

I tried using xdmp:http-post and xdmp:invoke both in for loops and also without 
for loops.

for example:

*xdmp:http-post (for loop) does not execute in parallel:

let $sub-search-results :=
    for $sub-search in $sub-searches
    return xdmp:http-post($endpoint....)

let $subsearch-results := 

    <subsearch-results>

        {$sub-search-results}

    </subsearch-results>




return $sub-search-results


*xdmp:http-post (no for loop) DOES execute in parallel:



let $sub-search-result-1 := xdmp:http-post($endpoint....)
let $sub-search-result-2 := xdmp:http-post($endpoint....)
let $sub-search-result-3 := xdmp:http-post($endpoint....)
let $sub-search-result-4 := xdmp:http-post($endpoint....)


let $subsearch-results := 
    <subsearch-results>
        {$sub-search-result-1}
        {$sub-search-result-2}
        {$sub-search-result-3}
        {$sub-search-result-4}
    </subsearch-results>


return $sub-search-results


I tried similar approaches using xdmp:invoke (both with and without a for loop) 
but neither would execute in parallel.

Does this sound right? I was expecting to be able to get parallel execution in 
a for loop using xdmp:http-post (I even tried fn:unordered but it had not 
effect). and I was expecting to get parallel execution using xdmp:invoke 
somehow but I couldn't.

The http-post approach isn't too bad for my situation but it feels like a 
little bit of a hack just to get parallel execution. Are there any other ways?

thanks,
Ryan
                                          
_______________________________________________
General mailing list
[email protected]
http://community.marklogic.com/mailman/listinfo/general

Reply via email to