List of usage examples for org.apache.solr.client.solrj.impl BinaryResponseParser BinaryResponseParser
BinaryResponseParser
From source file:com.doculibre.constellio.wicket.servlet.SolrServletEmulator.java
License:Open Source License
/** * Parse the solr response to named list (need to create solrj query * respond).// ww w .j a v a 2s.com * * @param req * The request. * @param rsp * The response. * @return The named list. */ public NamedList<Object> getParsedResponse(SolrQueryRequest req, SolrQueryResponse rsp) { try { BinaryResponseWriter writer = new BinaryResponseWriter(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); writer.write(bos, req, rsp); BinaryResponseParser parser = new BinaryResponseParser(); return parser.processResponse(new ByteArrayInputStream(bos.toByteArray()), "UTF-8"); } catch (Exception ex) { throw new RuntimeException(ex); } }
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./*from www. j a va 2 s . co 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.mmj.app.lucene.solr.client.SolrClient.java
License:Open Source License
private HttpSolrServer newSolrServer(String solrServerUrl) { HttpSolrServer solrServer = new HttpSolrServer(solrServerUrl); solrServer.setSoTimeout(60000);//w ww .j a v a2 s .com solrServer.setConnectionTimeout(5000); solrServer.setDefaultMaxConnectionsPerHost(50); solrServer.setMaxTotalConnections(100); solrServer.setFollowRedirects(false); solrServer.setAllowCompression(false); solrServer.setMaxRetries(1); solrServer.setParser(new BinaryResponseParser()); solrServer.setRequestWriter(new BinaryRequestWriter()); commit(); return solrServer; }
From source file:com.mustardgrain.solr.SolrClient.java
License:Apache License
/** The provided httpClient should use a multi-threaded connection manager */ public SolrClient(HttpClient httpClient, String... solrServerUrl) throws MalformedURLException { this(httpClient, new BinaryResponseParser(), solrServerUrl); }
From source file:com.nkang.kxmoment.util.SolrUtils.HttpSolrServer.java
License:Apache License
/** * @param baseURL/*from w w w . j a va 2 s.com*/ * The URL of the Solr server. For example, " * <code>http://localhost:8983/solr/</code>" if you are using the * standard distribution Solr webapp on your local machine. */ public HttpSolrServer(String baseURL) { this(baseURL, null, new BinaryResponseParser()); }
From source file:com.nkang.kxmoment.util.SolrUtils.HttpSolrServer.java
License:Apache License
public HttpSolrServer(String baseURL, HttpClient client) { this(baseURL, client, new BinaryResponseParser()); }
From source file:com.su.search.client.solrj.PaHttpSolrServer.java
License:Apache License
public PaHttpSolrServer(String baseURL, String password) { this(baseURL, null, new BinaryResponseParser()); this.password = password; }
From source file:com.su.search.client.solrj.PaHttpSolrServer.java
License:Apache License
/** * @param baseURL/*from ww w. j a v a 2s . co m*/ * The URL of the Solr server. For example, " * <code>http://localhost:8983/solr/</code>" if you are using the * standard distribution Solr webapp on your local machine. */ public PaHttpSolrServer(String baseURL) { this(baseURL, null, new BinaryResponseParser()); }
From source file:com.su.search.client.solrj.PaHttpSolrServer.java
License:Apache License
public PaHttpSolrServer(String baseURL, HttpClient client) { this(baseURL, client, new BinaryResponseParser()); }
From source file:net.yacy.cora.federate.solr.connector.RemoteSolrConnector.java
License:Open Source License
@Override public QueryResponse getResponseByParams(ModifiableSolrParams params) throws IOException { // during the solr query we set the thread name to the query string to get more debugging info in thread dumps String q = params.get(CommonParams.Q); String fq = params.get(CommonParams.FQ); String threadname = Thread.currentThread().getName(); if (q != null) Thread.currentThread().setName("solr query: q = " + q + (fq == null ? "" : ", fq = " + fq)); QueryRequest request = new QueryRequest(params); ResponseParser responseParser = useBinaryResponseWriter ? new BinaryResponseParser() : new XMLResponseParser(); request.setResponseParser(responseParser); long t = System.currentTimeMillis(); NamedList<Object> result = null; try {/*from w ww. j a va 2 s.co m*/ result = this.server.request(request); } catch (final Throwable e) { //ConcurrentLog.logException(e); throw new IOException(e.getMessage()); /* Log.logException(e); server = instance.getServer(this.corename); super.init(server); try { result = server.request(request); } catch (final Throwable e1) { throw new IOException(e1.getMessage()); } */ } QueryResponse response = new QueryResponse(result, this.server); response.setElapsedTime(System.currentTimeMillis() - t); if (q != null) Thread.currentThread().setName(threadname); return response; }