@Test public void testMultiQuery() throws FoxtrotException, JsonProcessingException { HashMap<String, ActionRequest> requests = Maps.newHashMap(); Query query = new Query(); query.setTable(TestUtils.TEST_TABLE_NAME); ResultSort resultSort = new ResultSort(); resultSort.setOrder(ResultSort.Order.asc); resultSort.setField("_timestamp"); query.setSort(resultSort); requests.put("1", query); CountRequest countRequest = new CountRequest(); countRequest.setTable(TestUtils.TEST_TABLE_NAME); countRequest.setField("os"); countRequest.setDistinct(false); requests.put("2", countRequest); MultiQueryRequest multiQueryRequest = new MultiQueryRequest(requests); ActionResponse actionResponse = getQueryExecutor().execute(multiQueryRequest); MultiQueryResponse multiQueryResponse = null; if(actionResponse instanceof MultiQueryResponse) { multiQueryResponse = (MultiQueryResponse)actionResponse; } assertNotNull(multiQueryResponse); QueryResponse queryResponse = (QueryResponse)multiQueryResponse.getResponses() .get("1"); CountResponse countResponse = (CountResponse)multiQueryResponse.getResponses() .get("2"); assertEquals(9, countResponse.getCount()); }
@Override public ActionResponse execute(MultiQueryRequest parameter) { MultiSearchRequestBuilder multiSearchRequestBuilder = getRequestBuilder(parameter); try { LOGGER.info("Search: {}", multiSearchRequestBuilder); MultiSearchResponse multiSearchResponse = multiSearchRequestBuilder.execute() .actionGet(); return getResponse(multiSearchResponse, parameter); } catch (ElasticsearchException e) { throw FoxtrotExceptions.createQueryExecutionException(parameter, e); } }
MultiQueryAction extends Action<MultiQueryRequest> { @Override public ActionResponse execute(MultiQueryRequest parameter) { MultiSearchRequestBuilder multiSearchRequestBuilder = getRequestBuilder(parameter); try { LOGGER.info("Search: {}", multiSearchRequestBuilder); MultiSearchResponse multiSearchResponse = multiSearchRequestBuilder.execute() .actionGet(); return getResponse(multiSearchResponse, parameter); } catch (ElasticsearchException e) { throw FoxtrotExceptions.createQueryExecutionException(parameter, e); } } }
MultiQueryAction extends Action<MultiQueryRequest> { @Override public ActionResponse execute(MultiQueryRequest parameter) { MultiSearchRequestBuilder multiSearchRequestBuilder = getRequestBuilder(parameter); try { LOGGER.info("Search: {}", multiSearchRequestBuilder); MultiSearchResponse multiSearchResponse = multiSearchRequestBuilder.execute() .actionGet(); return getResponse(multiSearchResponse, parameter); } catch (ElasticsearchException e) { throw FoxtrotExceptions.createQueryExecutionException(parameter, e); } } MultiQueryAction(MultiQueryRequest parameter, AnalyticsLoader analyticsLoader); }
MultiQueryAction extends Action<MultiQueryRequest> { @Override public ActionResponse execute(MultiQueryRequest parameter) { MultiSearchRequestBuilder multiSearchRequestBuilder = getRequestBuilder(parameter); try { LOGGER.info("Search: {}", multiSearchRequestBuilder); MultiSearchResponse multiSearchResponse = multiSearchRequestBuilder.execute() .actionGet(); return getResponse(multiSearchResponse, parameter); } catch (ElasticsearchException e) { throw FoxtrotExceptions.createQueryExecutionException(parameter, e); } } MultiQueryAction(MultiQueryRequest parameter, AnalyticsLoader analyticsLoader); @Override void preprocess(); @Override String getMetricKey(); @Override String getRequestCacheKey(); @Override void validateImpl(MultiQueryRequest parameter); @Override ActionResponse execute(MultiQueryRequest parameter); @Override MultiSearchRequestBuilder getRequestBuilder(MultiQueryRequest parameter); @Override ActionResponse getResponse(org.elasticsearch.action.ActionResponse multiSearchResponse, MultiQueryRequest parameter); }
MultiQueryAction extends Action<MultiQueryRequest> { @Override public ActionResponse execute(MultiQueryRequest parameter) { MultiSearchRequestBuilder multiSearchRequestBuilder = getRequestBuilder(parameter); try { LOGGER.info("Search: {}", multiSearchRequestBuilder); MultiSearchResponse multiSearchResponse = multiSearchRequestBuilder.execute() .actionGet(); return getResponse(multiSearchResponse, parameter); } catch (ElasticsearchException e) { throw FoxtrotExceptions.createQueryExecutionException(parameter, e); } } MultiQueryAction(MultiQueryRequest parameter, AnalyticsLoader analyticsLoader); @Override void preprocess(); @Override String getMetricKey(); @Override String getRequestCacheKey(); @Override void validateImpl(MultiQueryRequest parameter); @Override ActionResponse execute(MultiQueryRequest parameter); @Override MultiSearchRequestBuilder getRequestBuilder(MultiQueryRequest parameter); @Override ActionResponse getResponse(org.elasticsearch.action.ActionResponse multiSearchResponse, MultiQueryRequest parameter);  }