Hi Günter,
Here’s one way to do it:
declare variable $QUERY external := 'mailto'; declare variable $START external := 1; declare variable $MAX external := 50;
let $hits := db:open('data')//text() [. contains text { $QUERY }] let $count := count($hits) return <div>{ <p>{ concat($count, ' results, showing ', $START, ' – ', min(($count, $START + $MAX - 1)), ':') }</p>, <ol>{ for $hit in subsequence($hits, $START, $MAX) return <li>{ $hit }</li> }</ol> }</div>
As Omar has already indicated, you can e.g. use fn:subsequence to limit the size of a result sequence. I have defined some external variables, which you can assign before running your query. If you use RESTXQ, you can supply them with query parameters.
Hope this helps, Christian
On Fri, Sep 25, 2020 at 1:23 PM Günter Dunz-Wolff guenter.dunzwolff@gmail.com wrote:
Hi all, is it possible to present the results of an XQuery search in parts of 50? In order to speed up the search, only the first 50 results should be displayed and only if the user is interested in further results, 50 new results each should be displayed. Is this even possible? I did not find anything about it in the documentation.
Example: let $collection := collection("data") let $hits := $collection//*:s[.//text() contains text {$query_string}] let $count_hits := count($hits) return
<div> { if $count_hits <= 50 then <ol> {for $hit in $hits return <li>{$hit}</li> </ol> else ??? } </div>
Thanks for any advice. Best regards Guenter