## org.apache.solr.client.solrj.impl
Class CommonsHttpSolrServer

    java.lang.Object
      org.apache.solr.client.solrj.SolrServer
          org.apache.solr.client.solrj.impl.CommonsHttpSolrServer

All Implemented Interfaces:
  Serializable

    public class CommonsHttpSolrServer

extends SolrServer

Since:
  solr 1.3
Version:
  $Id: CommonsHttpSolrServer.java 673528 2008-07-02 22:23:24Z yonik $
See Also:
  Serialized Form

Field Summary
`protected String` `_baseURL` The URL of the Solr server.
`protected org.apache.solr.common.params.ModifiableSolrParams` `_invariantParams`
`protected ResponseParser` `_parser`
`static String` `AGENT`

Constructor Summary
`CommonsHttpSolrServer(String solrServerUrl)`
`CommonsHttpSolrServer(String solrServerUrl, org.apache.commons.httpclient.HttpClient httpClient)` Talk to the Solr server via the given HttpClient.
`CommonsHttpSolrServer(String solrServerUrl, org.apache.commons.httpclient.HttpClient httpClient, boolean useMultiPartPost)`
`CommonsHttpSolrServer(String solrServerUrl, org.apache.commons.httpclient.HttpClient httpClient, ResponseParser parser)`
`CommonsHttpSolrServer(URL baseURL)`
`CommonsHttpSolrServer(URL baseURL, org.apache.commons.httpclient.HttpClient client)`
`CommonsHttpSolrServer(URL baseURL, org.apache.commons.httpclient.HttpClient client, boolean useMultiPartPost)`
`CommonsHttpSolrServer(URL baseURL, org.apache.commons.httpclient.HttpClient client, ResponseParser parser, boolean useMultiPartPost)`

Method Summary
`String` `getBaseURL()`
`org.apache.commons.httpclient.HttpClient` `getHttpClient()`
`org.apache.solr.common.params.ModifiableSolrParams` `getInvariantParams()` Parameters are added to ever request regardless.
`ResponseParser` `getParser()`
`org.apache.solr.common.util.NamedList<Object>` `request(SolrRequest request)` Process the request.
`org.apache.solr.common.util.NamedList<Object>` `request(SolrRequest request, ResponseParser processor)`
`void` `setAllowCompression(boolean allowCompression)` set allowCompression.
`void` `setBaseURL(String baseURL)`
`void` `setConnectionManagerTimeout(int timeout)` set connectionManagerTimeout on the HttpClient.
`void` `setConnectionTimeout(int timeout)` set connectionTimeout on the underlying HttpConnectionManager
`void` `setDefaultMaxConnectionsPerHost(int connections)` set maxConnectionsPerHost on the underlying HttpConnectionManager
`void` `setFollowRedirects(boolean followRedirects)` set followRedirects.
`void` `setMaxRetries(int maxRetries)` set maximum number of retries to attempt in the event of transient errors.
`void` `setMaxTotalConnections(int connections)` set maxTotalConnection on the underlying HttpConnectionManager
`void` `setParser(ResponseParser processor)` Note: Setting this value is not thread-safe.
`void` `setSoTimeout(int timeout)` set soTimeout (read timeout) on the underlying HttpConnectionManager.

Methods inherited from class org.apache.solr.client.solrj.SolrServer
`add, add, addBean, addBeans, commit, commit, deleteById, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### AGENT

    public static final String AGENT

### _baseURL

    protected String _baseURL

  The URL of the Solr server.

### _invariantParams

    protected org.apache.solr.common.params.ModifiableSolrParams _invariantParams

### _parser

    protected ResponseParser _parser

Constructor Detail

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(String solrServerUrl)
                          throws MalformedURLException

Parameters:
  `solrServerUrl` - The URL of the Solr server. For example, "`http://localhost:8983/solr/`" if you are using the standard distribution Solr webapp on your local machine.
Throws:
  `MalformedURLException`

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(String solrServerUrl,
                                 org.apache.commons.httpclient.HttpClient httpClient)
                          throws MalformedURLException

  Talk to the Solr server via the given HttpClient. The connection manager for the client should be a MultiThreadedHttpConnectionManager if this client is being reused across SolrServer instances, or of multiple threads will use this SolrServer.

  Throws:
    `MalformedURLException`

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(String solrServerUrl,
                                 org.apache.commons.httpclient.HttpClient httpClient,
                                 boolean useMultiPartPost)
                          throws MalformedURLException

Throws:
  `MalformedURLException`

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(String solrServerUrl,
                                 org.apache.commons.httpclient.HttpClient httpClient,
                                 ResponseParser parser)
                          throws MalformedURLException

Throws:
  `MalformedURLException`

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(URL baseURL)

Parameters:
  `baseURL` - The URL of the Solr server. For example, "`http://localhost:8983/solr/`" if you are using the standard distribution Solr webapp on your local machine.

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(URL baseURL,
                                 org.apache.commons.httpclient.HttpClient client)

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(URL baseURL,
                                 org.apache.commons.httpclient.HttpClient client,
                                 boolean useMultiPartPost)

### CommonsHttpSolrServer

    public CommonsHttpSolrServer(URL baseURL,
                                 org.apache.commons.httpclient.HttpClient client,
                                 ResponseParser parser,
                                 boolean useMultiPartPost)

Method Detail

### request

    public org.apache.solr.common.util.NamedList<Object> request(SolrRequest request)
                                                          throws SolrServerException,
                                                                 IOException

  Process the request. If `SolrRequest.getResponseParser()` is null, then use `getParser()`

  Specified by:
    `request` in class `SolrServer`
  Parameters:
    `request` - The `SolrRequest` to process
  Returns:
    The `NamedList` result
  Throws:
    `SolrServerException`
    `IOException`
  See Also:
    `request(org.apache.solr.client.solrj.SolrRequest, org.apache.solr.client.solrj.ResponseParser)`

### request

    public org.apache.solr.common.util.NamedList<Object> request(SolrRequest request,
                                                                 ResponseParser processor)
                                                          throws SolrServerException,
                                                                 IOException

  Throws:
    `SolrServerException`
    `IOException`

### getInvariantParams

    public org.apache.solr.common.params.ModifiableSolrParams getInvariantParams()

  Parameters are added to ever request regardless. This may be a place to add something like an authentication token.

### getBaseURL

    public String getBaseURL()

### setBaseURL

    public void setBaseURL(String baseURL)

### getParser

    public ResponseParser getParser()

### setParser

    public void setParser(ResponseParser processor)

  Note: Setting this value is not thread-safe.

  Parameters:
    `processor` - The `ResponseParser`

### getHttpClient

    public org.apache.commons.httpclient.HttpClient getHttpClient()

### setConnectionTimeout

    public void setConnectionTimeout(int timeout)

  set connectionTimeout on the underlying HttpConnectionManager

### setConnectionManagerTimeout

    public void setConnectionManagerTimeout(int timeout)

  set connectionManagerTimeout on the HttpClient.

### setSoTimeout

    public void setSoTimeout(int timeout)

  set soTimeout (read timeout) on the underlying HttpConnectionManager. This is desirable for queries, but probably not for indexing.

### setDefaultMaxConnectionsPerHost

    public void setDefaultMaxConnectionsPerHost(int connections)

  set maxConnectionsPerHost on the underlying HttpConnectionManager

### setMaxTotalConnections

    public void setMaxTotalConnections(int connections)

  set maxTotalConnection on the underlying HttpConnectionManager

### setFollowRedirects

    public void setFollowRedirects(boolean followRedirects)

  set followRedirects. This defaults to false under the assumption that if you are following a redirect to get to a Solr installation, something is misconfigured somewhere.

### setAllowCompression

    public void setAllowCompression(boolean allowCompression)

  set allowCompression. If compression is enabled, both gzip and deflate compression will be accepted in the HTTP response.

### setMaxRetries

    public void setMaxRetries(int maxRetries)

  set maximum number of retries to attempt in the event of transient errors. Default: 0 (no) retries. No more than 1 recommended.

Copyright © 2008 Apache Software Foundation. All Rights Reserved.