[
https://issues.apache.org/jira/browse/SOLR-6777?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14222095#comment-14222095
]
Shawn Heisey commented on SOLR-6777:
------------------------------------
[~joey_dale], for *queries*, specifying the collection is very easy without any
additional methods.
{code}
SolrQuery query = new SolrQuery();
query.setQuery("*:*");
query.set("collection","test");
QueryResponse rsp = solr.query(query);
{code}
It's when you want to add or delete that things get a lot less straightforward.
I believe that the code example in the description of SOLR-3920 is the current
way to update multiple collections.
Convenience methods are a really good idea for add, commit, deleteByQuery, etc.
Although dealing with multiple collections is very easy for queries, it may
also be a good idea to build a convenience method for that too.
> Create convenience methods in CloudSolrServer to specify the collection to
> act on, on a per request basis.
> ----------------------------------------------------------------------------------------------------------
>
> Key: SOLR-6777
> URL: https://issues.apache.org/jira/browse/SOLR-6777
> Project: Solr
> Issue Type: Improvement
> Components: clients - java
> Reporter: Joey Dale
> Priority: Minor
> Labels: newbie
>
> As a user of solrcloud as a NoSQL datastore, with components of my complex
> data model stored in many collections, I would like to easily pass in the
> collection name for each query/add/delete statement via an overloaded method
> that accepts a String equal to the name of the collection.
> Currently there exists methods to set the default collection for a
> CloudSolrServer instance. This losses its luster in a multithreaded
> environment. The work arounds to date are passing in a SolrParam on the
> Update handlers, but on the Query handles you are forced to basically
> maintain a CloudSolrServer instance for each collection you want to interact
> with, and never call setDefaultCollect after creation.
> Here are some examples:
> CloudSolrServer solr = new CloudSolr(zkHost);
> solr.addBeans(beans, collection);
> solr.addBeans(beans, collection, commitWithin);
> solr.commit(collection, commitWithin);
> solr.optimize(collection);
> SolrQuery query = new SolrQuery();
> query.setQuery("*:*");
> QueryResponse rsp = solr.query(query, collection);
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]