max items to be returned in Extended Query Request

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

max items to be returned in Extended Query Request

Ulrike Schmidt
Hello,

I am rather new to exist ans so my question is probably very basic.

I am using Perl with the REST-Style Web API. In the documentation for
POST requests at http://exist-db.org/devguide.html#N102F5 I found that
it is possible to set the maximum number of items to be returned. I
would like to return all items, but setting no value for max returned 10
items.

I could guess the approximate number of items beforehand, but is there a
more elegant way to return just all items? Which part of the
documentation did I possibly miss?

Uli




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: max items to be returned in Extended Query Request

Michael Beddow-2
Ulrike Schmidt wrote:

> I am using Perl with the REST-Style Web API. In the documentation for
> POST requests at http://exist-db.org/devguide.html#N102F5 I found that
> it is possible to set the maximum number of items to be returned. I
> would like to return all items, but setting no value for max returned 10
> items.
>
> I could guess the approximate number of items beforehand, but is there a
> more elegant way to return just all items? Which part of the
> documentation did I possibly miss?

Well, you can set an impossibly high value for the maximum number of results
to return (not elegant, I agree, but extremely Perlish). Or you can query
initially for a hit-count only, then re-query using this information. This
isn't as wasteful as it sounds if you use eXist's session-persistence
support. You can get the entire result-set in your first query, stash it in
a session on the back end, and return just the results count to your
application. In subsequent queries (maybe after warning a user whose queries
would involve more serialized output than is feasible or desirable)  you can
request any desired subset of the query results by position numbers, and
eXist will pull them from the session cache, serialize and return them as
required. You need to employ the HTTP::Cookies module in your LWP
transactions to maintain state with the REST server, but once (easily) set
up that's completely transparent. Just remember to set autosave->1 when you
instantiate your cookie jar object, overriding the default.

Michael Beddow



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: max items to be returned in Extended Query Request

Ulrike Schmidt
Michael Beddow wrote:

>Or you can query
>initially for a hit-count only, then re-query using this information. This
>isn't as wasteful as it sounds if you use eXist's session-persistence
>support.
>
Is there a more elegant way than to parse <exist:result
xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:hits="1005"
 exist:start="1" exist:count="10">

I RTFM-ed but did not find it ...

Uli





-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open
Reply | Threaded
Open this post in threaded view
|

Re: max items to be returned in Extended Query Request

Michael Beddow-2
Ulrike Schmidt  wrote

> Is there a more elegant way than to parse <exist:result
> xmlns:exist="http://exist.sourceforge.net/NS/exist" exist:hits="1005"
>  exist:start="1" exist:count="10">
>

let $hits := your query expression here
let $count := count($hits)
return
<result> {$count} hits"</result>

If, in addition, you store $hits in a session variable, you can come back
later and get as many as you want without repeating the query.

Michael Beddow



-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Exist-open mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/exist-open