Another approach would be to use an external application executed by a cron or some scheduler that would post the file to solr using the class.
org.apache.solr.util.SimplePostTool SimplePostTool postTool = new SimplePostTool(new URL(SOLR_URL)); for (File file : outputDir.listFiles(/* smoe filtering */) ){ try { postTool.postFile(file, System.out, "xml"); //move or delete the posted files boolean success = file.renameTo(new File(postedDir, file.getName())); if (!success) { LOGGER.info("File was not successfully moved :"+file.getName()); } } catch (Exception e) { LOGGER.error("Error during file post :" + file.getCanonicalPath(), e); //behavior to take if one file couldn't be posted, we stop or continue if (failfast) { return; } } } // solr commit postTool.commit(); Attention must be paid on the coordination between the schedule and the "hot directory" to avoid posting files that wouldn't be entirely written: to avoid posting uncompleted files. Regards, Michel On Mon, Jul 9, 2012 at 6:49 PM, Jay Hill <jayallenh...@gmail.com> wrote: > I may have found a good solution. I implemented my own SolrEventListener: > > public class DynamicIndexerEventListener > implementsorg.apache.solr.core.SolrEventListener{ > > ... > > and then called it with a "firstSearcher" element in solrconfig.xml: > > <listener event="firstSearcher" > class="com.bestbuy.search.foundation.solr.DynamicIndexerEventListener" /> > > Then in the newSearcher() method I startup up the thread for my polling > UpdateRequestHandler. > > This seems to work, but if anyone has a better (or more tested) approach > please let us know. > > > -Jay > > On Mon, Jul 9, 2012 at 2:33 PM, Jay Hill <jayallenh...@gmail.com> wrote: > > > I'm writing a custom update request handler that will poll a "hot" > > directory for Solr xml files and index anything it finds there. The > custom > > class implements Runnable, and when the run method is called the loop > > starts to do the polling. How can I tell Solr to load this class on > startup > > to fire off the run() method? > > > > Thanks, > > -Jay > > >