Search in sources :

Example 6 with CountResponse

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();
}
Also used : CountRequest(org.elasticsearch.client.core.CountRequest) CountResponse(org.elasticsearch.client.core.CountResponse)

Example 7 with CountResponse

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();
}
Also used : CountRequest(org.elasticsearch.client.core.CountRequest) CountResponse(org.elasticsearch.client.core.CountResponse)

Example 8 with CountResponse

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();
}
Also used : RefreshRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.refresh.RefreshRequest) CountRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountRequest) CountResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse)

Example 9 with CountResponse

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();
}
Also used : CountRequest(org.elasticsearch.client.core.CountRequest) CountResponse(org.elasticsearch.client.core.CountResponse) Span(co.elastic.apm.agent.impl.transaction.Span) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) AbstractEsClientInstrumentationTest(co.elastic.apm.agent.esrestclient.AbstractEsClientInstrumentationTest) Test(org.junit.Test)

Example 10 with CountResponse

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();
}
Also used : CountRequest(org.elasticsearch.client.core.CountRequest) CountResponse(org.elasticsearch.client.core.CountResponse)

Aggregations

CountRequest (org.elasticsearch.client.core.CountRequest)10 CountResponse (org.elasticsearch.client.core.CountResponse)10 IOException (java.io.IOException)3 RestHighLevelClient (org.elasticsearch.client.RestHighLevelClient)3 SearchSourceBuilder (org.elasticsearch.search.builder.SearchSourceBuilder)3 Test (org.junit.Test)2 AbstractEsClientInstrumentationTest (co.elastic.apm.agent.esrestclient.AbstractEsClientInstrumentationTest)1 Span (co.elastic.apm.agent.impl.transaction.Span)1 Stopwatch (com.google.common.base.Stopwatch)1 Ticker (com.google.common.base.Ticker)1 LoadingCache (com.google.common.cache.LoadingCache)1 DatasourceClient (io.openk9.datasource.client.api.DatasourceClient)1 HttpResponseWriter (io.openk9.http.util.HttpResponseWriter)1 RouterHandler (io.openk9.http.web.RouterHandler)1 DocumentEntityRequest (io.openk9.index.writer.entity.model.DocumentEntityRequest)1 JsonFactory (io.openk9.json.api.JsonFactory)1 Datasource (io.openk9.model.Datasource)1 PluginDriverManagerClient (io.openk9.plugin.driver.manager.client.api.PluginDriverManagerClient)1 ReactorNettyUtils (io.openk9.reactor.netty.util.ReactorNettyUtils)1 ReactorActionListener (io.openk9.search.client.api.ReactorActionListener)1