I am using Solr 1.3
I have a "solr.RandomSortField" type dynamic field which I use to randomize
my results.

I am in a tricky situation. I need to randomize only "certain results" in my
Hits.
To elaborate, I have a integer field called "category_id". When performing a
query, I need to get results from all categories and place the ones from
SOME_CAT_ID at the top. I achieved this by populating a separate dynamic
field while indexing data. i.e When a doc is added to the index a field
called "dynamic_cat_id_SOME_CAT_ID" is populated with its category id. While
querying, I know the value of SOME_CAT_ID, so adding a
"sort=dynamic_cat_id_SOME_CAT_ID asc, score desc" to my query, works
absolutely fine.

So far so good. I am now supposed to randomize the results for
category_id=SOME_CAT_ID, i.e results at the top. My understading is that
adding "sort=dynamic_cat_id_SOME_CAT_ID asc, *my_dynamic_random_field_SOME_SEED
asc*, score desc" to the query would randomize all the results. This is not
desired. I only want to randomize the one's at the top
(category_id=SOME_CAT_ID), rest should be ordered based on relevance score.

Two simple questions:

   1. Is there a way to achieve this without writing any custom code?
   2. If the answer to #1 is "no", the Where should I start? I glanced the
   RandomSortField class but could not figure out how to proceed. Do I need to
   create a custom FieldType? Can I extend the RandomSortField and override the
   sorting behaviour?

Any help would be appreciated.

Cheers
Avlesh

Reply via email to