Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

SOLR dynamic fields and random filtering

SOLR dynamic fields and random filtering

Explorer

I would like to perform a random sort of data coming from database using SOLR. I found that SOLR Training has already a dynamic Field that I can use with random field type :

<types>
   ...
   <fieldType name="random" />
  ... 
</types>
<fields>
    ...
   <dynamicField name="random*" type="random" indexed="true" stored="false"/>
    ...
</fields>

But I don't understant how to fill the random* column. My data are issues from data import using SQL query.

Must I fill the column in db-data-config.xml and in which way ?

Thanks.

1 REPLY 1
Highlighted

Re: SOLR dynamic fields and random filtering

Explorer

The RandomSortField type doesn't hold any data, so you don't need to define any column in your database to go into it.

When you query your data, you'll add "sort=random_<seed>" to the query parameters, where you define some value (whatever you want) for the <seed>. If you issue the same query later with the same seed value, you should get the same results (assuming you haven't indexed new data).

Note the field type definition in the example is not complete. It should be:

<fieldType name="random" class="solr.RandomSortField />

You can of course give the field type any name you want, but would then need to modify your dynamic field rule to reference the proper field type name.

Don't have an account?
Coming from Hortonworks? Activate your account here