use of org.elasticsearch.client.core.CountResponse in project elasticflow by springwings.
the class EsWriter method getDocumentNums.
private long getDocumentNums(String instance, String storeId) throws Exception {
String iName = Common.getStoreName(instance, storeId);
CountRequest countRequest = new CountRequest(iName);
CountResponse response = getESC().getClient().count(countRequest, RequestOptions.DEFAULT);
return response.getCount();
}
use of org.elasticsearch.client.core.CountResponse in project jobrunr by jobrunr.
the class ElasticSearchStorageProvider method countJobs.
long countJobs(QueryBuilder queryBuilder) throws IOException {
CountRequest countRequest = new CountRequest(jobIndexName);
countRequest.query(queryBuilder);
CountResponse countResponse = client.count(countRequest, RequestOptions.DEFAULT);
return countResponse.getCount();
}
use of org.elasticsearch.client.core.CountResponse in project graylog2-server by Graylog2.
the class MessagesES7IT method messageCount.
@Override
protected long messageCount(String indexName) {
this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.indices().refresh(new RefreshRequest(), requestOptions));
final CountRequest countRequest = new CountRequest(indexName);
final CountResponse result = this.elasticsearch.elasticsearchClient().execute((c, requestOptions) -> c.count(countRequest, requestOptions));
return result.getCount();
}
use of org.elasticsearch.client.core.CountResponse in project apm-agent-java by elastic.
the class AbstractEs6_4ClientInstrumentationTest method testCountRequest_validateSpanContentAndDbContext.
@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();
}
use of org.elasticsearch.client.core.CountResponse in project geo-platform by geosdi.
the class ElasticSearchRestDAO method count.
/**
* @param theQueryBuilder
* @return {@link Long}
* @throws Exception
*/
@Override
public Long count(@Nonnull(when = NEVER) QueryBuilder theQueryBuilder) throws Exception {
checkArgument(theQueryBuilder != null, "The Parameter queryBuilder must not be null.");
CountRequest countRequest = new CountRequest(this.getIndexName());
countRequest.query(theQueryBuilder);
logger.trace("#########################QueryBuilder : \n{}\n\n", theQueryBuilder.toString());
CountResponse countResponse = this.elasticSearchRestHighLevelClient.count(countRequest, DEFAULT);
if (countResponse.status() != OK) {
throw new IllegalStateException("Problem in Search : " + countResponse.status());
}
return countResponse.getCount();
}
Aggregations