private String getFieldNameOfUniqueKey() { final SolrQuery solrQuery = new SolrQuery(); try { solrQuery.setRequestHandler("/schema/uniquekey"); final QueryRequest req = new QueryRequest(solrQuery); if (isBasicAuthEnabled()) { req.setBasicAuthCredentials(getUsername(), getPassword()); } return(req.process(getSolrClient()).getResponse().get("uniqueKey").toString()); } catch (SolrServerException | IOException e) { getLogger().error("Solr query to retrieve uniqueKey-field failed due to {}", new Object[]{solrQuery.toString(), e}, e); throw new ProcessException(e); } }
final QueryResponse response = req.process(getSolrClient()); final SolrDocumentList documentList = response.getResults();
final QueryResponse response = req.process(getSolrClient()); timer.stop();
public QueryResponse request(QueryRequest request) { try { return request.process(this._client, this._collection); } catch (SolrServerException | IOException ex) { LOGGER.error("Failed to run query request {}", request, ex); } return null; }
/** * Performs a query to the Solr server * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server */ public QueryResponse query(String collection, SolrParams params) throws SolrServerException, IOException { return new QueryRequest(params).process(this, collection); }
/** * Performs a query to the Solr server * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server */ public QueryResponse query(String collection, SolrParams params) throws SolrServerException, IOException { return new QueryRequest(params).process(this, collection); }
/** * Performs a query to the Solr server * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * @param method specifies the HTTP method to use for the request, such as GET or POST * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server */ public QueryResponse query(String collection, SolrParams params, METHOD method) throws SolrServerException, IOException { return new QueryRequest(params, method).process(this, collection); }
public QueryResponse query(SolrParams params) throws SolrServerException { return new QueryRequest( params ).process( this ); }
public QueryResponse query(SolrParams params, METHOD method) throws SolrServerException { return new QueryRequest( params, method ).process( this ); }
/** * Performs a query to the Solr server * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * @param method specifies the HTTP method to use for the request, such as GET or POST * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server */ public QueryResponse query(String collection, SolrParams params, METHOD method) throws SolrServerException, IOException { return new QueryRequest(params, method).process(this, collection); }
public void open() throws IOException { if(cache != null) { cloudSolrClient = cache.getCloudSolrClient(zkHost); } else { final List<String> hosts = new ArrayList<>(); hosts.add(zkHost); cloudSolrClient = new CloudSolrClient.Builder(hosts, Optional.empty()).build(); } ModifiableSolrParams params = getParams(this.props); params.remove(SORT); //Override any sort. Random rand = new Random(); int seed = rand.nextInt(); String sortField = "random_"+seed; params.add(SORT, sortField+" asc"); QueryRequest request = new QueryRequest(params); try { QueryResponse response = request.process(cloudSolrClient, collection); SolrDocumentList docs = response.getResults(); documentIterator = docs.iterator(); } catch (Exception e) { throw new IOException(e); } }
public NamedList<Double> call() throws Exception { ModifiableSolrParams params = new ModifiableSolrParams(); HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl); params.add(DISTRIB, "false"); params.add("fq","{!significantTerms}"); for(String key : paramsMap.keySet()) { params.add(key, paramsMap.get(key)); } params.add("minDocFreq", Float.toString(minDocFreq)); params.add("maxDocFreq", Float.toString(maxDocFreq)); params.add("minTermLength", Integer.toString(minTermLength)); params.add("field", field); params.add("numTerms", String.valueOf(numTerms*5)); QueryRequest request= new QueryRequest(params); QueryResponse response = request.process(solrClient); NamedList res = response.getResponse(); return res; } }
public NamedList<Double> call() throws Exception { ModifiableSolrParams params = new ModifiableSolrParams(); HttpSolrClient solrClient = cache.getHttpSolrClient(baseUrl); params.add(DISTRIB, "false"); params.add("fq","{!igain}"); for(String key : paramsMap.keySet()) { params.add(key, paramsMap.get(key)); } params.add("outcome", outcome); params.add("positiveLabel", Integer.toString(positiveLabel)); params.add("field", field); params.add("numTerms", String.valueOf(numTerms)); QueryRequest request= new QueryRequest(params); QueryResponse response = request.process(solrClient); NamedList res = response.getResponse(); return res; } }
/** * Query solr, and stream the results. Unlike the standard query, this will * send events for each Document rather then add them to the QueryResponse. * * Although this function returns a 'QueryResponse' it should be used with care * since it excludes anything that was passed to callback. Also note that * future version may pass even more info to the callback and may not return * the results in the QueryResponse. * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * @param callback the callback to stream results to * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since solr 5.1 */ public QueryResponse queryAndStreamResponse(String collection, SolrParams params, StreamingResponseCallback callback) throws SolrServerException, IOException { ResponseParser parser = new StreamingBinaryResponseParser(callback); QueryRequest req = new QueryRequest(params); req.setStreamingResponseCallback(callback); req.setResponseParser(parser); return req.process(this, collection); }
public void open() throws IOException { cloudSolrClient = cache.getCloudSolrClient(zkHost); ModifiableSolrParams params = getParams(this.props); StringBuilder builder = new StringBuilder(); for(String key : mltParams) { if(params.get(key) != null) { builder.append(" " + key + "=" + params.get(key)); params.remove(key); } } String k = params.get("k"); if(k != null) { params.add(ROWS, k); params.remove(k); } params.add(Q, "{!mlt"+builder.toString()+"}"+id); QueryRequest request = new QueryRequest(params); try { QueryResponse response = request.process(cloudSolrClient, collection); SolrDocumentList docs = response.getResults(); documentIterator = docs.iterator(); } catch (Exception e) { throw new IOException(e); } }
/** * Query solr, and stream the results. Unlike the standard query, this will * send events for each Document rather then add them to the QueryResponse. * * Although this function returns a 'QueryResponse' it should be used with care * since it excludes anything that was passed to callback. Also note that * future version may pass even more info to the callback and may not return * the results in the QueryResponse. * * @param collection the Solr collection to query * @param params an object holding all key/value parameters to send along the request * @param callback the callback to stream results to * * @return a {@link org.apache.solr.client.solrj.response.QueryResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since solr 5.1 */ public QueryResponse queryAndStreamResponse(String collection, SolrParams params, StreamingResponseCallback callback) throws SolrServerException, IOException { ResponseParser parser = new StreamingBinaryResponseParser(callback); QueryRequest req = new QueryRequest(params); req.setStreamingResponseCallback(callback); req.setResponseParser(parser); return req.process(this, collection); }
QueryResponse response = request.process(solrClient); NamedList res = response.getResponse();
private String getFieldNameOfUniqueKey() { final SolrQuery solrQuery = new SolrQuery(); try { solrQuery.setRequestHandler("/schema/uniquekey"); final QueryRequest req = new QueryRequest(solrQuery); if (isBasicAuthEnabled()) { req.setBasicAuthCredentials(getUsername(), getPassword()); } return(req.process(getSolrClient()).getResponse().get("uniqueKey").toString()); } catch (SolrServerException | IOException e) { getLogger().error("Solr query to retrieve uniqueKey-field failed due to {}", new Object[]{solrQuery.toString(), e}, e); throw new ProcessException(e); } }
final QueryResponse response = req.process(getSolrClient()); final SolrDocumentList documentList = response.getResults();
final QueryResponse response = req.process(getSolrClient()); timer.stop();