lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Grange <rgra...@dollardays.com>
Subject Re: Random search result
Date Tue, 04 Mar 2008 20:27:56 GMT
Your best bet would probably be to send a query for one record, get the 
number of matching records, and then repeat several requests for a 
single record starting at a random number from 1 to the number of 
records discovered on the first query.

So if you do a search for state:NJ with start=0 and rows=1, you can pull 
out the /response/result[numFound] value.  Next, you can query it for 
the same search criteria with a start={random number from 0 to 
numFound-1} and rows=1, grabbing the result each time.  The first set of 
search results will likely still be in the cache for you to get 10 such 
queries through quickly.  The trick is to make sure you don't pick the 
same random number twice.  Perhaps an associative array using the number 
as the key to you can check the existence of.

Ryan Grange, IT Manager
DollarDays International, LLC
rgrange@dollardays.com
480-922-8155 x106



Evgeniy Strokin wrote:
> I want to get sample from my search result. Not first 10 but 10 random (really random,
not pseudo random) documents.
> For example if I run simple query like STATE:NJ no order by any field, just the query
and get 10 first documents from my result set, will it be random 10 or pseudo random, like
first 10 indexed or something like this? 
>  
> Thank you
> Gene
>   

Mime
View raw message