本文整理汇总了Java中org.elasticsearch.action.count.CountRequestBuilder类的典型用法代码示例。如果您正苦于以下问题:Java CountRequestBuilder类的具体用法?Java CountRequestBuilder怎么用?Java CountRequestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CountRequestBuilder类属于org.elasticsearch.action.count包,在下文中一共展示了CountRequestBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: count
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@Override
public Long count(Class clazz, @Nullable QueryBuilder queryBuilder) {
CountRequestBuilder countRequestBuilder = client.prepareCount(getIndexName());
if (queryBuilder != null) {
countRequestBuilder.setQuery(queryBuilder);
}
String typeName = MappingProcessor.getIndexTypeName(clazz);
countRequestBuilder.setTypes(typeName);
if (logger.isDebugEnabled()) {
String queryStr = "";
if (queryBuilder != null) {
queryStr = queryBuilder.buildAsBytes().toUtf8();
}
logger.debug("Count for class: {}, query: {}", clazz.getSimpleName(), queryStr);
}
return countRequestBuilder.get().getCount();
}
示例2: countRequest
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
/**
* With retry
*/
public static long countRequest(final String index, final QueryBuilder query, final String... types) {
CountResponse response = withRetry(new ElasticsearchWithRetry<CountResponse>() {
public CountResponse call(Client client) throws NoNodeAvailableException {
CountRequestBuilder request_builder = new CountRequestBuilder(client);
request_builder.setIndices(index);
request_builder.setTypes(types);
request_builder.setQuery(query);
return request_builder.execute().actionGet();
}
});
if (response == null) {
return 0;
}
return response.getCount();
}
示例3: count
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
/**
* http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-count.html
* @param query
* @param type
* @return
*/
public <T> long count(SearchCriteria query, String type) throws SearchException {
Timer.Context timer = searchMetrics.indexTimer(type, "count");
try {
CountRequestBuilder request = client.prepareCount(indexName).setTypes(type);
if(query!=null && query.getQuery()!=null){
request.setQuery(query.getQuery());
}
searchMetrics.indexIncr(type, "count");
return request.execute().actionGet().getCount();
} catch (Exception e) {
searchMetrics.failedIncr(type, "count", e);
logger.error("count Error. ", e);
throw new SearchException("count Error. typeName="+type, e);
}finally {
timer.stop();
}
}
示例4: waitForUpdateCompletion
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@SneakyThrows({InterruptedException.class})
protected void waitForUpdateCompletion(int inv) {
while(true){
CountRequestBuilder countRequestBuilder = client.prepareCount (dummyIndexName (getNUMROWS(), getNUMCOLS(), inv)).setTypes (getDocumentType ());
CountResponse countResponse = countRequestBuilder.execute ().actionGet ();
if(countResponse.getCount ()==getNUMROWS ())
break;
Thread.sleep (500);
}
}
示例5: waitForUpdateCompletion
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@SneakyThrows({InterruptedException.class})
protected void waitForUpdateCompletion() {
while(true){
CountRequestBuilder countRequestBuilder = client.prepareCount (adminHelper.dummyName (getNUMROWS(), getNUMCOLS())).setTypes (getDocumentType ());
CountResponse countResponse = countRequestBuilder.execute ().actionGet ();
if(countResponse.getCount ()==getNUMROWS ())
break;
Thread.sleep (500);
}
}
示例6: count
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@Override
public CountResponse count(String[] indices, String... types) {
CountRequestBuilder countRequestBuilder = esClient.getClient().prepareCount(indices);
if (types != null && types.length > 0) {
countRequestBuilder.setTypes(types);
}
countRequestBuilder.setQuery(this.queryBuilder);
return countRequestBuilder.execute().actionGet();
}
示例7: prepareCount
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@Override
public CountRequestBuilder prepareCount(String... indices) {
deprecationLogger.deprecated("the count api is deprecated and will be removed from the java api in the next major version");
return new CountRequestBuilder(this, CountAction.INSTANCE).setIndices(indices);
}
示例8: count
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
@Override
public long count(Set<String> types, String query, Set<String> filterIds, EzSecurityToken userToken)
throws TException {
final Stopwatch watch = LoggingUtils.createStopWatch();
CountRequestBuilder requestBuilder = client.prepareCount(indexName);
final VisibilityFilterConfig filterConfig =
new VisibilityFilterConfig(VISIBILITY_FIELD, EnumSet.of(Permission.DISCOVER));
final ScriptFilterBuilder visibilityFilter = getVisibilityFilter(userToken, filterConfig);
if (!types.isEmpty()) {
requestBuilder = requestBuilder.setTypes(types.toArray(new String[types.size()]));
}
if (!filterIds.isEmpty()) {
if (StringUtils.isNotEmpty(query)) {
requestBuilder = requestBuilder.setQuery(
QueryBuilders.filteredQuery(
QueryBuilders.boolQuery().must(parseQuery(query)).must(
QueryBuilders.idsQuery().addIds(
filterIds.toArray(new String[filterIds.size()]))), visibilityFilter));
} else {
requestBuilder = requestBuilder.setQuery(
QueryBuilders.filteredQuery(
QueryBuilders.idsQuery().addIds(filterIds.toArray(new String[filterIds.size()])),
visibilityFilter));
}
} else if (StringUtils.isNotEmpty(query)) {
requestBuilder = requestBuilder.setQuery(QueryBuilders.filteredQuery(parseQuery(query), visibilityFilter));
} else {
requestBuilder = requestBuilder.setQuery(
QueryBuilders.filteredQuery(
QueryBuilders.matchAllQuery(), visibilityFilter));
}
final CountResponse response = requestBuilder.get();
LoggingUtils.stopAndLogStopWatch(logger, watch, "Count");
return response.getCount();
}
示例9: count
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
private long count() throws InterruptedException, ExecutionException {
return new CountRequestBuilder(esClient.client())
.setIndices(EsSchema.CONTENT_INDEX)
.execute().get().getCount();
}
示例10: prepareCount
import org.elasticsearch.action.count.CountRequestBuilder; //导入依赖的package包/类
/**
* A count of all the documents matching a specific query.
* @deprecated use {@link #prepareSearch(String...)} instead and set size to 0
*/
@Deprecated
CountRequestBuilder prepareCount(String... indices);