At the bottom of each NixMash post you'll see a Solr More Like This List for related posts. Here are the related items for post titled "Returning a Java Object List in RabbitMQ RPC."
I covered creating a More Like This list with Spring Solr in this NixMash post. In that post I also covered the Solr configuration issues to support the More Like This Solr Handler in the Solr Administration Dashboard. Here we'll focus on how to return a More Like This list in Apache SolrJ.
Without delay here's a @Test Method demonstrating More Like This with SolrJ.
(1) We configure our MoreLikeThis Query. Notice the setShowDebugInfo(true) Query Property. Enabling Debug Info is of course very helpful to learn more about the results of your query when in development.
(2) We're not working directly with our response = client.query(query) as we would normally. That returns only our focal SolrDocument, or document with id:598. Instead we will be working with a SolrDocumentList.
(3) In our application we want to return Post objects so we populate our List<Post> from SolrDocument fields.
(4) For completeness we perform a simple test to confirm that our Post list has 4 items.
Now take a minute to view the More Like This posts shown below for this post about More Like This!