org.apache.solr.client.solrj.impl

## Class CloudSolrClient

- java.lang.Object
- - org.apache.solr.client.solrj.SolrClient
  - - org.apache.solr.client.solrj.impl.BaseCloudSolrClient
    - - org.apache.solr.client.solrj.impl.CloudSolrClient

All Implemented Interfaces:
  Closeable, Serializable, AutoCloseable

    public class CloudSolrClient
    extends BaseCloudSolrClient

SolrJ client class to communicate with SolrCloud. Instances of this class communicate with Zookeeper to discover Solr endpoints for SolrCloud collections, and then use the `LBHttpSolrClient` to issue requests. This class assumes the id field for your documents is called 'id' - if this is not the case, you must set the right name with `BaseCloudSolrClient.setIdField(String)`.

See Also:
  Serialized Form

### Nested Class Summary

Nested Classes
`static class` `CloudSolrClient.Builder` Constructs `CloudSolrClient` instances from provided configuration.
`static class` `CloudSolrClient.RouteException` Deprecated. since Solr 8.0
`static class` `CloudSolrClient.RouteResponse` Deprecated. since Solr 8.0

### Field Summary

Fields
`static String` `STATE_VERSION`

### Fields inherited from class org.apache.solr.client.solrj.impl.BaseCloudSolrClient

`collectionStateCache`

### Constructor Summary

Constructors
`protected` `CloudSolrClient(CloudSolrClient.Builder builder)` Create a new client object that connects to Zookeeper and is always aware of the SolrCloud state.

### Method Summary

All Methods Instance Methods Concrete Methods Deprecated Methods
`void` `close()`
`CloudSolrClient.RouteResponse` `condenseResponse(NamedList response, int timeMillis)` Deprecated. since Solr 8.0
`protected Map<String,LBHttpSolrClient.Req>` `createRoutes(UpdateRequest updateRequest, ModifiableSolrParams routableParams, DocCollection col, DocRouter router, Map<String,List<String>> urlMap, String idField)`
`ClusterStateProvider` `getClusterStateProvider()`
`org.apache.http.client.HttpClient` `getHttpClient()`
`LBHttpSolrClient` `getLbClient()`
`protected CloudSolrClient.RouteException` `getRouteException(SolrException.ErrorCode serverError, NamedList<Throwable> exceptions, Map<String,? extends LBSolrClient.Req> routes)`
`void` `setConnectionTimeout(int timeout)` Deprecated. since 7.0 Use `CloudSolrClient.Builder` methods instead.
`void` `setParallelUpdates(boolean parallelUpdates)` Deprecated. since 7.2 Use `CloudSolrClient.Builder` methods instead.
`void` `setSoTimeout(int timeout)` Deprecated. since 7.0 Use `CloudSolrClient.Builder` methods instead.
`protected boolean` `wasCommError(Throwable rootCause)`

### Methods inherited from class org.apache.solr.client.solrj.impl.BaseCloudSolrClient

`condenseResponse, connect, connect, getDefaultCollection, getDocCollection, getIdField, getMinAchievedReplicationFactor, getParser, getRequestWriter, getShardReplicationFactor, getZkHost, getZkStateReader, isDirectUpdatesToLeadersOnly, isParallelUpdates, isUpdatesToLeaders, objectList, registerCollectionStateWatcher, registerDocCollectionWatcher, request, requestWithRetryOnStaleState, sendRequest, setCollectionCacheTTl, setDefaultCollection, setIdField, setParallelCacheRefreshes, setParser, setRequestWriter, setRetryExpiryTime, setZkClientTimeout, setZkConnectTimeout, waitForState, waitForState`

### Methods inherited from class org.apache.solr.client.solrj.SolrClient

`add, add, add, add, add, add, add, add, add, add, addBean, addBean, addBean, addBean, addBeans, addBeans, addBeans, addBeans, addBeans, addBeans, commit, commit, commit, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, deleteByQuery, deleteByQuery, getBinder, getById, getById, getById, getById, getById, getById, getById, getById, optimize, optimize, optimize, optimize, optimize, optimize, ping, query, query, query, query, queryAndStreamResponse, queryAndStreamResponse, queryAndStreamResponse, request, rollback, rollback`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### STATE_VERSION

    public static final String STATE_VERSION

See Also:
  Constant Field Values

### Constructor Detail

#### CloudSolrClient

    protected CloudSolrClient(CloudSolrClient.Builder builder)

Create a new client object that connects to Zookeeper and is always aware of the SolrCloud state. If there is a fully redundant Zookeeper quorum and SolrCloud has enough replicas for every shard in a collection, there is no single point of failure. Updates will be sent to shard leaders by default.

Parameters:
  `builder` - a `CloudSolrClient.Builder` with the options used to create the client.

### Method Detail

#### setSoTimeout

    @Deprecated
    public void setSoTimeout(int timeout)

Deprecated. since 7.0 Use `CloudSolrClient.Builder` methods instead.

#### createRoutes

    protected Map<String,LBHttpSolrClient.Req> createRoutes(UpdateRequest updateRequest,
                                                            ModifiableSolrParams routableParams,
                                                            DocCollection col,
                                                            DocRouter router,
                                                            Map<String,List<String>> urlMap,
                                                            String idField)

Overrides:
  `createRoutes` in class `BaseCloudSolrClient`

#### getRouteException

    protected CloudSolrClient.RouteException getRouteException(SolrException.ErrorCode serverError,
                                                               NamedList<Throwable> exceptions,
                                                               Map<String,? extends LBSolrClient.Req> routes)

Overrides:
  `getRouteException` in class `BaseCloudSolrClient`

#### setParallelUpdates

    @Deprecated
    public void setParallelUpdates(boolean parallelUpdates)

Deprecated. since 7.2 Use `CloudSolrClient.Builder` methods instead.

#### condenseResponse

    @Deprecated
    public CloudSolrClient.RouteResponse condenseResponse(NamedList response,
                                                                      int timeMillis)

Deprecated. since Solr 8.0

Overrides:
  `condenseResponse` in class `BaseCloudSolrClient`

#### close

    public void close()
               throws IOException

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Overrides:
  `close` in class `BaseCloudSolrClient`
Throws:
  `IOException`

#### getLbClient

    public LBHttpSolrClient getLbClient()

Specified by:
  `getLbClient` in class `BaseCloudSolrClient`

#### getHttpClient

    public org.apache.http.client.HttpClient getHttpClient()

#### setConnectionTimeout

    @Deprecated
    public void setConnectionTimeout(int timeout)

Deprecated. since 7.0 Use `CloudSolrClient.Builder` methods instead.

#### getClusterStateProvider

    public ClusterStateProvider getClusterStateProvider()

Specified by:
  `getClusterStateProvider` in class `BaseCloudSolrClient`

#### wasCommError

    protected boolean wasCommError(Throwable rootCause)

Specified by:
  `wasCommError` in class `BaseCloudSolrClient`