/** * 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 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 4.0 */ public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback) throws SolrServerException, IOException { return queryAndStreamResponse(null, params, callback); }
@Override public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback) throws SolrServerException, IOException { this.logger.debug("Execute Solr query and stream response [{}]", params); return this.server.queryAndStreamResponse(params, callback); }
/** * 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 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 4.0 */ public QueryResponse queryAndStreamResponse(SolrParams params, StreamingResponseCallback callback) throws SolrServerException, IOException { return queryAndStreamResponse(null, params, callback); }
private void streamNextDocumentsFromSolr() { SolrQuery solrQuery = query.getCopy(); solrQuery.setRows(nrOfTimeSeriesPerBatch); solrQuery.setStart(currentDocumentCount); solrStreamingHandler.init(nrOfTimeSeriesPerBatch, currentDocumentCount); try { //Steam from solr connection.queryAndStreamResponse(solrQuery, solrStreamingHandler); //Convert the returning solr documents using the converter convertStream(); } catch (SolrServerException | IOException e) { LOGGER.warn("Exception while streaming the data points from Solr", e); } }
private void streamNextDocumentsFromSolr() { SolrQuery solrQuery = query.getCopy(); solrQuery.setRows(nrOfTimeSeriesPerBatch); solrQuery.setStart(currentDocumentCount); solrStreamingHandler.init(nrOfTimeSeriesPerBatch, currentDocumentCount); try { //Steam from solr connection.queryAndStreamResponse(solrQuery, solrStreamingHandler); //Convert the returning solr documents using the converter convertStream(); } catch (SolrServerException | IOException e) { LOGGER.warn("Exception while streaming the data points from Solr", e); } }
private void initialStream(SolrQuery query, SolrClient connection) { try { //Make a copy of the query SolrQuery solrQuery = query.getCopy(); //We override the number of rows solrQuery.setRows(nrOfTimeSeriesPerBatch); //And the start solrQuery.setStart(currentDocumentCount); //init the streaming handler with solrStreamingHandler.init(nrOfTimeSeriesPerBatch, currentDocumentCount); QueryResponse response = connection.queryAndStreamResponse(solrQuery, solrStreamingHandler); //Set the global values nrOfAvailableTimeSeries = response.getResults().getNumFound(); queryStart = (long) response.getResponseHeader().get(ChronixSolrStorageConstants.QUERY_START_LONG); queryEnd = (long) response.getResponseHeader().get(ChronixSolrStorageConstants.QUERY_END_LONG); //Data is filled. We need not stream until it is read out needStream = false; } catch (SolrServerException | IOException e) { LOGGER.error("SolrServerException occurred while querying server.", e); } }
private void initialStream(SolrQuery query, SolrClient connection) { try { //Make a copy of the query SolrQuery solrQuery = query.getCopy(); //We override the number of rows solrQuery.setRows(nrOfTimeSeriesPerBatch); //And the start solrQuery.setStart(currentDocumentCount); //init the streaming handler with solrStreamingHandler.init(nrOfTimeSeriesPerBatch, currentDocumentCount); QueryResponse response = connection.queryAndStreamResponse(solrQuery, solrStreamingHandler); //Set the global values nrOfAvailableTimeSeries = response.getResults().getNumFound(); queryStart = (long) response.getResponseHeader().get(ChronixSolrStorageConstants.QUERY_START_LONG); queryEnd = (long) response.getResponseHeader().get(ChronixSolrStorageConstants.QUERY_END_LONG); //Data is filled. We need not stream until it is read out needStream = false; } catch (SolrServerException | IOException e) { LOGGER.error("SolrServerException occurred while querying server.", e); } }