use of org.elasticsearch.action.count.CountRequestBuilder in project alien4cloud by alien4cloud.
the class ESGenericSearchDAO method count.
@Override
public <T> long count(Class<T> clazz, QueryBuilder query) {
String indexName = getIndexForType(clazz);
String typeName = MappingBuilder.indexTypeFromClass(clazz);
CountRequestBuilder countRequestBuilder = getClient().prepareCount(indexName).setTypes(typeName);
if (query != null) {
countRequestBuilder.setQuery(query);
}
return countRequestBuilder.execute().actionGet().getCount();
}
Aggregations