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());
}
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();
}
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();
}
Aggregations