Search in sources :

Example 1 with CountRequestBuilder

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();
}
Also used : CountRequestBuilder(org.elasticsearch.action.count.CountRequestBuilder)

Aggregations

CountRequestBuilder (org.elasticsearch.action.count.CountRequestBuilder)1