List of usage examples for org.apache.solr.client.solrj.impl HttpClientUtil PROP_FOLLOW_REDIRECTS
String PROP_FOLLOW_REDIRECTS
To view the source code for org.apache.solr.client.solrj.impl HttpClientUtil PROP_FOLLOW_REDIRECTS.
Click Source Link
From source file:com.ilscipio.scipio.solr.util.ScipioHttpSolrClient.java
License:Apache License
/** * Creates a new client from URL and username/password, where all operations will use * the given auth.//ww w. j av a 2 s . c o m * <p> * DEV NOTE: Implementation must be maintained with the superclass; the default values * are taken from {@link HttpSolrClient.Builder} and are subject to change at solrj updates. */ public static HttpSolrClient create(String baseURL, HttpClient httpClient, String solrUsername, String solrPassword, Integer maxConnections, Integer maxConnectionsPerHost, Integer connectTimeout, Integer socketTimeout) { if (httpClient == null) { ModifiableSolrParams params = new ModifiableSolrParams(); if (maxConnections != null) { params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, maxConnections); } if (maxConnectionsPerHost != null) { params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, maxConnectionsPerHost); } params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, true); httpClient = HttpClientUtil.createClient(params); } // DEV NOTE: the defaults must match what HttpSolrClient.Builder does! Must keep up to date! HttpSolrClient client = new ScipioHttpSolrClient(baseURL, httpClient, new BinaryResponseParser(), false, new ModifiableSolrParams(), solrUsername, solrPassword); // TODO: In Solr 7, these are deprecated and moved to Builder/constructor if (connectTimeout != null) { client.setConnectionTimeout(connectTimeout); } if (socketTimeout != null) { client.setSoTimeout(socketTimeout); } return client; }
From source file:com.nkang.kxmoment.util.SolrUtils.HttpSolrServer.java
License:Apache License
public HttpSolrServer(String baseURL, HttpClient client, ResponseParser parser) { this.baseUrl = baseURL; if (baseUrl.endsWith("/")) { baseUrl = baseUrl.substring(0, baseUrl.length() - 1); }//from www .ja v a 2 s .c o m if (baseUrl.indexOf('?') >= 0) { throw new RuntimeException( "Invalid base url for solrj. The base URL must not contain parameters: " + baseUrl); } if (client != null) { httpClient = client; internalClient = false; } else { internalClient = true; ModifiableSolrParams params = new ModifiableSolrParams(); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS, 128); params.set(HttpClientUtil.PROP_MAX_CONNECTIONS_PER_HOST, 32); params.set(HttpClientUtil.PROP_FOLLOW_REDIRECTS, followRedirects); httpClient = HttpClientUtil.createClient(params); } this.parser = parser; }