Search in sources :

Example 1 with CountResponse

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse in project graylog2-server by Graylog2.

the class IndexToolsAdapterES7 method count.

@Override
public long count(Set<String> indices, Optional<Set<String>> includedStreams) {
    final CountRequest request = new CountRequest(indices.toArray(new String[0]), buildStreamIdFilter(includedStreams)).indicesOptions(IndicesOptions.fromOptions(true, false, true, false));
    final CountResponse result = client.execute((c, requestOptions) -> c.count(request, requestOptions), "Unable to count documents of index.");
    return result.getCount();
}
Also used : CountRequest(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountRequest) CountResponse(org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse)

Example 2 with CountResponse

use of org.graylog.shaded.elasticsearch7.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)

Aggregations

CountRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountRequest)2 CountResponse (org.graylog.shaded.elasticsearch7.org.elasticsearch.client.core.CountResponse)2 RefreshRequest (org.graylog.shaded.elasticsearch7.org.elasticsearch.action.admin.indices.refresh.RefreshRequest)1