/** * Given a field name and an IndexReader, get a random hash seed. * Using dynamic fields, you can force the random order to change */ private static int getSeed(String fieldName, IndexReader r) { SolrIndexReader top = (SolrIndexReader)r; int base=0; while (top.getParent() != null) { base += top.getBase(); top = top.getParent(); } // calling getVersion() on a segment will currently give you a null pointer exception, so // we use the top-level reader. return fieldName.hashCode() + base + (int)top.getVersion(); }