You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Camel Christophe <cc...@cls.fr> on 2011/04/13 14:49:13 UTC

[Fuseki] How to know result size ?

Hi everybody,

I'm writing a small web interface and that displays results with
pagination. So I send a sparql query with the keyword "LIMIT" and
"OFFSET". To calculate the total number of pages, I need to know the
total number of results for a query. 

How can I do that ? It seems that the count (*) syntax does not work
with Fuseki.

Thanks.

Chris.

Re: [Fuseki] How to know result size ?

Posted by Damian Steer <d....@bristol.ac.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/04/11 14:20, Camel Christophe wrote:
>> count certainly does work: could you provide an example of it not
> working?
> 
>>   select (count(*) as ?total) {
>>       ... condition ...
>>   }
> 
> ah, ok. I forgot the parenthesis. Great, it works now :

Yep, sparql 1.1 is picky.

...

> 
>> Are you trying to do this in just one query?
> 
> If only it were possible ?

Well it is (UNION subselects for example), but you're much better off
with two queries.

Damian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2lpoUACgkQAyLCB+mTtykY3ACgxnVlu8dyokub4JCkRvqUMydM
Ul8An0nBBuhjKpKQgARDSA8yZIVxpooG
=V/L0
-----END PGP SIGNATURE-----

RE: [Fuseki] How to know result size ?

Posted by Camel Christophe <cc...@cls.fr>.
> count certainly does work: could you provide an example of it not
working?

>   select (count(*) as ?total) {
>       ... condition ...
>   }

ah, ok. I forgot the parenthesis. Great, it works now :

SELECT  (count(*) as ?total)
WHERE
  { 
    GRAPH ?graph {
       ?s ?p ?o
    }
  }

returns

---------
| total |
=========
| 50296 |
---------

> Are you trying to do this in just one query?

If only it were possible ?

Re: [Fuseki] How to know result size ?

Posted by Damian Steer <d....@bristol.ac.uk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 13/04/11 13:49, Camel Christophe wrote:
> Hi everybody,
> 
> I'm writing a small web interface and that displays results with
> pagination. So I send a sparql query with the keyword "LIMIT" and
> "OFFSET". To calculate the total number of pages, I need to know the
> total number of results for a query. 
> 
> How can I do that ? It seems that the count (*) syntax does not work
> with Fuseki.

count certainly does work: could you provide an example of it not working?

   select (count(*) as ?total) {
       ... condition ...
   }

Are you trying to do this in just one query?

Damian

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2lnp4ACgkQAyLCB+mTtym+jQCg3FktmVpjiIqVGwMFSETHt4YT
rmwAn1XxI1eHPWgKprpXNIuXUU/MgZAX
=kcPK
-----END PGP SIGNATURE-----