Search code examples
javaxmlsolrsolrj

Programmatically load data into solr using solrj and java


How can I load data from an xml file into solr using the solrj API?


Solution

  • With Java 6, you can use Xpath to fetch what you need from your xml file. Then, you populate a SolrInputDocument from what you extracted from the xml. When that document contains everything you need, you submit it to Solr using the add method of SolrServer.