On 6/25/2014 3:27 PM, Michael Della Bitta wrote:
> The subject line kind of says it all... this is the latest thing we have
> noticed that doesn't seem to have made it in. Am I missing something?

This code:

        SolrServer server;

        server = new HttpSolrServer("http://server:port/solr/corename";);
        ((HttpSolrServer) server).setMaxRetries(1);
        ((HttpSolrServer) server).setConnectionTimeout(5000);

        SolrQuery q = new SolrQuery();
        q.setRequestHandler("/get");
        q.set("id","ai_spa509997");
        System.out.println(q);
        QueryResponse r = server.query(q);
        System.out.println(r);

Produced this output:

qt=%2Fget&id=ai_spa509997
{doc=SolrDocument{location=PARIS,FRANCE,
photographer_id=22213,[lots_redacted]}}

> Other awkwardness was doing a deleteByQuery against a collection other than
> the defaultCollection, and trying to share a CloudSolrServer among
> different objects that were writing and reading against multiple
> collections.

If you set the "collection" parameter on a request to the name of the
collection you want to query/update, that should do what you're after. 
You'll need to do all changes with an UpdateRequest object -- the
syntactic sugar methods (add, deleteByQuery, etc) don't handle cases
where you need to set parameters on the request.

> We managed to hack around the former by doing it with an UpdateRequest. I'm
> wondering if a valid solution to the latter is actually to create one
> CloudSolrServer, rip the zkStateReader out of it, and stuff it in
> subsequent ones. Is that a bad idea? It seems like there might be some
> overhead to having several going in the same process that could be avoided,
> but maybe I'm overcomplicating things.

Another possibility is to create multiple CloudSolrServer objects and
use 'setDefaultCollection' on each of them, but that seems like complete
overkill unless you've got a small number of collections.  If you are
absolutely sure that you won't have multiple threads using the
CloudSolrServer object, you could call setDefaultCollection before each
use ... but IMHO that's sloppy coding.

Thanks,
Shawn

Reply via email to