public class HttpSolrServer extends SolrServer
Modifier and Type | Class and Description |
---|---|
static class |
HttpSolrServer.RemoteSolrException
Subclass of SolrException that allows us to capture an arbitrary HTTP
status code that may have been returned by the remote server or a
proxy along the way.
|
Modifier and Type | Field and Description |
---|---|
static String |
AGENT
User-Agent String.
|
protected String |
baseUrl
The URL of the Solr server.
|
protected ModifiableSolrParams |
invariantParams
Default value: null / empty.
|
protected ResponseParser |
parser
Default response parser is BinaryResponseParser
This parser represents the default Response Parser chosen to parse the
response if the parser were not specified as part of the request.
|
protected RequestWriter |
requestWriter
The RequestWriter used to write all requests to Solr
|
Constructor and Description |
---|
HttpSolrServer(String baseURL) |
HttpSolrServer(String baseURL,
org.apache.http.client.HttpClient client) |
HttpSolrServer(String baseURL,
org.apache.http.client.HttpClient client,
ResponseParser parser) |
Modifier and Type | Method and Description |
---|---|
UpdateResponse |
add(Iterator<SolrInputDocument> docIterator)
Adds the documents supplied by the given iterator.
|
UpdateResponse |
addBeans(Iterator<?> beanIterator)
Adds the beans supplied by the given iterator.
|
String |
getBaseURL() |
org.apache.http.client.HttpClient |
getHttpClient()
Return the HttpClient this instance uses.
|
ModifiableSolrParams |
getInvariantParams()
Retrieve the default list of parameters are added to every request
regardless.
|
ResponseParser |
getParser() |
Set<String> |
getQueryParams() |
boolean |
isUseMultiPartPost() |
NamedList<Object> |
request(SolrRequest request)
Process the request.
|
NamedList<Object> |
request(SolrRequest request,
ResponseParser processor) |
void |
setAllowCompression(boolean allowCompression)
Allow server->client communication to be compressed.
|
void |
setBaseURL(String baseURL) |
void |
setConnectionTimeout(int timeout)
HttpConnectionParams.setConnectionTimeout
|
void |
setDefaultMaxConnectionsPerHost(int max)
Set the maximum number of connections that can be open to a single host at
any given time.
|
void |
setFollowRedirects(boolean followRedirects)
Configure whether the client should follow redirects or not.
|
void |
setMaxRetries(int maxRetries)
Set maximum number of retries to attempt in the event of transient errors.
|
void |
setMaxTotalConnections(int max)
Set the maximum number of connections that can be open at any given time.
|
void |
setParser(ResponseParser processor)
Note: This setter method is not thread-safe.
|
void |
setQueryParams(Set<String> queryParams)
Expert Method.
|
void |
setRequestWriter(RequestWriter requestWriter) |
void |
setSoTimeout(int timeout)
Set SoTimeout (read timeout).
|
void |
setUseMultiPartPost(boolean useMultiPartPost)
Set the multipart connection properties
|
void |
shutdown()
Close the
ClientConnectionManager from the internal client. |
add, add, add, add, addBean, addBean, addBeans, addBeans, commit, commit, commit, deleteById, deleteById, deleteById, deleteById, deleteByQuery, deleteByQuery, getBinder, optimize, optimize, optimize, ping, query, query, queryAndStreamResponse, rollback
public static final String AGENT
protected String baseUrl
protected ModifiableSolrParams invariantParams
protected volatile ResponseParser parser
BinaryResponseParser
protected volatile RequestWriter requestWriter
RequestWriter
public HttpSolrServer(String baseURL)
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.public HttpSolrServer(String baseURL, org.apache.http.client.HttpClient client)
public HttpSolrServer(String baseURL, org.apache.http.client.HttpClient client, ResponseParser parser)
public void setQueryParams(Set<String> queryParams)
queryParams
- set of param keys to only send via the query stringpublic NamedList<Object> request(SolrRequest request) throws SolrServerException, IOException
SolrRequest.getResponseParser()
is
null, then use getParser()
request
in class SolrServer
request
- The SolrRequest
to processNamedList
resultIOException
- If there is a low-level I/O error.SolrServerException
request(org.apache.solr.client.solrj.SolrRequest,
org.apache.solr.client.solrj.ResponseParser)
public NamedList<Object> request(SolrRequest request, ResponseParser processor) throws SolrServerException, IOException
SolrServerException
IOException
public ModifiableSolrParams getInvariantParams()
invariantParams
public String getBaseURL()
public void setBaseURL(String baseURL)
public ResponseParser getParser()
public void setParser(ResponseParser processor)
processor
- Default Response Parser chosen to parse the response if the parser
were not specified as part of the request.SolrRequest.getResponseParser()
public org.apache.http.client.HttpClient getHttpClient()
public void setConnectionTimeout(int timeout)
timeout
- Timeout in millisecondspublic void setSoTimeout(int timeout)
timeout
- Timeout in millisecondspublic void setFollowRedirects(boolean 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.
public void setAllowCompression(boolean allowCompression)
public void setMaxRetries(int maxRetries)
Maximum number of retries to attempt in the event of transient errors. Default: 0 (no) retries. No more than 1 recommended.
maxRetries
- No more than 1 recommendedpublic void setRequestWriter(RequestWriter requestWriter)
public UpdateResponse add(Iterator<SolrInputDocument> docIterator) throws SolrServerException, IOException
docIterator
- the iterator which returns SolrInputDocument instancesSolrServerException
IOException
public UpdateResponse addBeans(Iterator<?> beanIterator) throws SolrServerException, IOException
beanIterator
- the iterator which returns BeansSolrServerException
IOException
public void shutdown()
ClientConnectionManager
from the internal client.shutdown
in class SolrServer
public void setDefaultMaxConnectionsPerHost(int max)
public void setMaxTotalConnections(int max)
public boolean isUseMultiPartPost()
public void setUseMultiPartPost(boolean useMultiPartPost)
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.