Search in sources :

Example 1 with Count

use of io.searchbox.core.Count in project herd by FINRAOS.

the class IndexFunctionsDaoImpl method getNumberOfTypesInIndex.

@Override
public long getNumberOfTypesInIndex(String indexName, String documentType) {
    Count count = new Count.Builder().addIndex(indexName).addType(documentType).build();
    JestResult jestResult = jestClientHelper.executeAction(count);
    return Long.parseLong(jestResult.getSourceAsString());
}
Also used : Count(io.searchbox.core.Count) JestResult(io.searchbox.client.JestResult)

Example 2 with Count

use of io.searchbox.core.Count in project graylog2-server by Graylog2.

the class MessagesES6IT method messageCount.

@Override
protected long messageCount(String indexName) {
    final Count count = new Count.Builder().addIndex(indexName).build();
    final CountResult result = JestUtils.execute(jestClient(elasticsearch), count, () -> "Unable to count documents");
    return result.getCount().longValue();
}
Also used : Count(io.searchbox.core.Count) CountResult(io.searchbox.core.CountResult)

Example 3 with Count

use of io.searchbox.core.Count in project graylog2-server by Graylog2.

the class IndexToolsAdapterES6 method count.

@Override
public long count(Set<String> indices, Optional<Set<String>> includedStreams) {
    final SearchSourceBuilder queryBuilder = new SearchSourceBuilder().query(buildStreamIdFilter(includedStreams));
    final Count.Builder builder = new Count.Builder().query(queryBuilder.toString()).addIndex(indices).addType(IndexMapping.TYPE_MESSAGE).setParameter(Parameters.IGNORE_UNAVAILABLE, true);
    final CountResult result = JestUtils.execute(jestClient, builder.build(), () -> "Unable to count documents of index.");
    return result.getCount().longValue();
}
Also used : FilterAggregationBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder) BoolQueryBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder) Count(io.searchbox.core.Count) CountResult(io.searchbox.core.CountResult) SearchSourceBuilder(org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder)

Aggregations

Count (io.searchbox.core.Count)3 CountResult (io.searchbox.core.CountResult)2 JestResult (io.searchbox.client.JestResult)1 BoolQueryBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.index.query.BoolQueryBuilder)1 FilterAggregationBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.aggregations.bucket.filter.FilterAggregationBuilder)1 SearchSourceBuilder (org.graylog.shaded.elasticsearch6.org.elasticsearch.search.builder.SearchSourceBuilder)1