On 3/11/2015 12:23 PM, tuxedomoon wrote:
> I have a SolrJ application that reads from a Redis queue and updates
> different collections based on the message content.  New collections are
> added without my knowledge, so I am creating SolrServer objects on the fly
> as follows:
>
>     def solrHost = "http://myhost/solr/"; (defined at startup)
>
>     def solrTarget = solrHost + collectionName
>     SolrServer solrServer = new CommonsHttpSolrServer(solrTarget)
>     updateResponse = solrServer.add(solrdoc)
>
>
> This does work but obviously creates a new CommonsHttpSolrServer instance
> for each message.  I assume GC will eliminate these but is there a way to do
> this with a single SolrServer object?  
>
> The SOLR host is version 3.5 and I am using the 3.5 jars for my application
> (not sure if that is necessary). 

What you want to accomplish should be possible, with some attention to
how SolrJ code is used.

We won't talk about SolrCloud, since you're not running Solr 4.x or
5.0.  Upgrading the server side is generally more involved than
upgrading the client side, and switching to SolrCloud can be a fairly
major conceptual leap.

To do what I'm thinking about, you will need to ugprade SolrJ.  When
SolrCloud is not involved, cross-version compatibility between Solr and
SolrJ is pretty good, although there can be some hiccups when crossing
the 3.x/4.x barrier relating to the update handlers.  Those hiccups are
normally easy to fix, but they are something you need to be aware of.

Once you've decided on whether you're upgrading Solr and which version
of SolrJ you will upgrade to, we can get down to the actual Java code
you'll need.  Note that recent 4.x and 5.0 versions require Java 7, so
if you're still on Java 6, you'll be limited to version 4.7.2.

It might even be possible to do this with SolrJ 3.5, but I am already
pretty familiar with how you can do it using new features in 4.x, and
since you're going to need to change the source code anyway, you might
as well take advantage of more modern client functionality that will
make the code easier to understand.

Just FYI, there are changes coming (currently planned for SolrJ 5.1)
that will make this VERY easy.

Thanks,
Shawn

Reply via email to