this.queryResponse = queryResponse; if (null != queryResponse && null != queryResponse.getResponseHeader()) { final NamedList<?> namedList = queryResponse.getResponseHeader(); for (Map.Entry entry : namedList) { map.put(entry.getKey(), entry.getValue());
public boolean execute() { SolrQuery query = queryGenerator.generate(); try { logger.debug("executing query: " + query); long init = System.nanoTime(); QueryResponse response = this.executeQuery(query); long clientTime = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - init); logger.debug(response.getResults().getNumFound() + " results found in " + response.getQTime() + " ms"); if(response.getQTime() < 0) { throw new RuntimeException("The query returned less than 0 as q time: " + response.getResponseHeader().get("q") + response.getQTime()); } executor.notifyQueryExecuted(response, clientTime); } catch (SolrServerException e) { logger.error("Error on Query " + query); e.printStackTrace(); executor.notifyError(new QueryException(e, query)); return false; } return true; }
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); } }
@SuppressWarnings("unchecked") public QueryLogValue(QueryResponse response) { Object parameter; error = false; NamedList<Object> params = (NamedList<Object>)response.getResponseHeader().get("params"); if(params!=null) { parameter = params.get("q"); if (parameter != null) { queryString = parameter.toString(); } parameter = params.get("fq"); if (parameter != null) { filterQueryString = parameter.toString(); } } facetQueryString = createFacetQuery(response.getFacetFields()); qTime = response.getQTime(); results = response.getResults().getNumFound(); }
solrDocumentList); queryResponse.getResponseHeader().setVal( queryResponse.getResponseHeader().indexOf(QUERY_TIME_NAME, 0), new Integer(new Long(System.currentTimeMillis() - startTime).intValue())); long highlightEndTime = System.currentTimeMillis(); if (core != null) { highlightComponenet = core.getSearchComponent("highlight"); solrQueryRequest = new LocalSolrQueryRequest(core, queryResponse.getResponseHeader()); int paramsIndex = queryResponse.getResponseHeader().indexOf(HEADER_PARAMS_NAME, 0); NamedList<Object> header = null; Object o = queryResponse.getResponseHeader().getVal(paramsIndex); if (o instanceof NamedList) { header = (NamedList<Object>)o;