org.elasticsearch.client.core.CountResponse Java Examples
The following examples show how to use
org.elasticsearch.client.core.CountResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractEs6_4ClientInstrumentationTest.java From apm-agent-java with Apache License 2.0 | 6 votes |
@Test public void testCountRequest_validateSpanContentAndDbContext() throws Exception { createDocument(); reporter.reset(); CountRequest countRequest = new CountRequest(INDEX); SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder(); countSourceBuilder.query(QueryBuilders.termQuery(FOO, BAR)); countRequest.source(countSourceBuilder); CountResponse responses = doCount(countRequest); assertThat(responses.getCount()).isEqualTo(1); List<Span> spans = reporter.getSpans(); assertThat(spans).hasSize(1); Span span = spans.get(0); validateSpanContent(span, String.format("Elasticsearch: POST /%s/_count", INDEX), 200, "POST"); validateDbContextContent(span, "{\"query\":{\"term\":{\"foo\":{\"value\":\"bar\",\"boost\":1.0}}}}"); deleteDocument(); }
Example #2
Source File: EsRestClientContainer.java From frostmourne with MIT License | 5 votes |
public long totalCount(BoolQueryBuilder boolQueryBuilder, String[] indices) throws IOException { CountRequest countRequest = new CountRequest(indices); SearchSourceBuilder countSourceBuilder = new SearchSourceBuilder(); countSourceBuilder.query(boolQueryBuilder); countRequest.source(countSourceBuilder); CountResponse countResponse = this.fetchHighLevelClient().count(countRequest, RequestOptions.DEFAULT); return countResponse.getCount(); }
Example #3
Source File: DefaultElasticSearchService.java From jetlinks-community with Apache License 2.0 | 5 votes |
@Override public Mono<Long> count(String index, QueryParam queryParam) { QueryParam param = queryParam.clone(); param.setPaging(false); param.setSorts(Collections.emptyList()); return doCount(createCountRequest(param, index)) .map(CountResponse::getCount) .defaultIfEmpty(0L) .onErrorReturn(err -> { log.error("query elastic error", err); return true; }, 0L); }
Example #4
Source File: DefaultElasticSearchService.java From jetlinks-community with Apache License 2.0 | 5 votes |
private Mono<CountResponse> doCount(Mono<CountRequest> requestMono) { return requestMono.flatMap((request) -> ReactorActionListener .<CountResponse>mono(listener -> restClient .getQueryClient() .countAsync(request, RequestOptions.DEFAULT, listener))) .onErrorResume(err -> { log.error("query elastic error", err); return Mono.empty(); }); }
Example #5
Source File: AbstractEs6_4ClientInstrumentationTest.java From apm-agent-java with Apache License 2.0 | 5 votes |
protected CountResponse doCount(CountRequest countRequest) throws IOException, ExecutionException, InterruptedException { if (async) { ClientMethod<CountRequest, CountResponse> method = (request, options, listener) -> client.countAsync(request, options, listener); return invokeAsync(countRequest, method); } return client.count(countRequest, RequestOptions.DEFAULT); }
Example #6
Source File: StatusMetricsBolt.java From storm-crawler with Apache License 2.0 | 4 votes |
@Override public void onResponse(CountResponse response) { ready = true; LOG.debug("Got {} counts for status:{}", response.getCount(), name); latestStatusCounts.put(name, response.getCount()); }