Marc-Alexandre Nolin wrote:
> Hello,
> 
> When I do the following query:
> 
> select distinct
> ?s
> where
> {
> ?s rdf:type <http://biology.com/Protein> .
> }
> limit 100
> 
> Lets say I have 20000 objects of type protein in the triplestore. I
> will receive a results containing 100 rows of 100 distinct proteins.
> If I run the same query again, I will receive the same 100 distinct
> proteins.
> 
> Is there a way to receive a RANDOM set 100 proteins everytime I run
> the query? I bet its not possible in Sparql itself, but could it be
> with the Virtuoso toolset of bif:_something_ ? If its not there, how
> can I expand the bif toolset ?
> 
> For example, it could be a query like this:
> 
> select distinct
> ?s
> where
> {
> ?s rdf:type <http://biology.com/Protein> .
> bif:random(?s, 100) .
> }
> 
> USE : bif:random(<variable you want a random set>, <the amount you want>)
> 
> Implemented that way, I could expand the query with other attribute.
> 
> select distinct
> ?s
> where
> {
> ?s rdf:type <http://biology.com/Protein> .
> bif:random(?s, 100) .
> ?s <http://biology.com/chromosomeNumber> ?cn .
> filter(?cn == 10) .
> }
> 
> Thanks,
> 
> Marc-Alexandre Nolin
> 

bif:rnd() is what you need afaik - you could try:

select ?s where { ?s rdf:type <http://biology.com/Protein> ;
<http://biology.com/chromosomeNumber> ?cn } order by asc(
bif:rnd(2000000000, ?s) ) limit 100 ;

regards!

Reply via email to