lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: Solr Random field
Date Mon, 26 Oct 2009 12:33:08 GMT
On Mon, Oct 26, 2009 at 7:47 AM, Pooja Verlani <pooja.verlani@gmail.com> wrote:
> No I dont have the field with this type and neither do I want to re-index ..
> is it possible otherwise ?

Your documents don't need the "random" field, only your schema does.
The example schema already contains the following:
<dynamicField name="random_*" type="random" />
Add this to your schema if you don't have it already.  You won't need
to reindex (just restart).

Then just append a seed to random_ when you sort:
  q=foo&sort=random_9582 desc

The comments for the random field in the schema contain more details:

    <!-- The "RandomSortField" is not used to store or search any
         data.  You can declare fields of this type it in your schema
         to generate pseudo-random orderings of your docs for sorting
         purposes.  The ordering is generated based on the field name
         and the version of the index, As long as the index version
         remains unchanged, and the same field name is reused,
         the ordering of the docs will be consistent.
         If you want different psuedo-random orderings of documents,
         for the same version of the index, use a dynamicField and
         change the name
     -->
    <fieldType name="random" class="solr.RandomSortField" indexed="true" />


-Yonik
http://www.lucidimagination.com

Mime
View raw message