I thought it would be interesting to follow-up on the previous post on Using SolrJ with Java Objects by looking at the working code rather than a sample object. If you recall, we’re converting NixMashup Links to individual posts and indexing them in Solr. Our Java Object is NixMashupLink, so without further chatter let’s look at the input of our List<NixMashupLink> Collection into Solr with SolrJ.
In the first approach (1) we’re entering the entire Collection at one time. This is much faster than (2) where we’re entering each record individually. I’m presenting both options because the more atomic approach in (2) wrapping exception handling around individual record entries can provide better information if there are problems.
Either way, SolrJ makes entering multiple records into a Solr index a breeze with very few lines of code.
We entered 263 individual links which you can see in the Solr Control Panel statistics for the NixMashup Collection.
Here are our NixMashupLink records as they appear in the Solr Index.
Pretty sweet all around.