Support Questions

Find answers, ask questions, and share your expertise
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

SOLR dynamic fields and random filtering


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 :

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

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 ?




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.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.