本文整理汇总了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();
}
开发者ID:kzwang,项目名称:elasticsearch-osem,代码行数:22,代码来源:ElasticSearchSearcherImpl.java
示例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();
}
开发者ID:hdsdi3g,项目名称:MyDMAM,代码行数:19,代码来源:Elasticsearch.java
示例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();
}
}
开发者ID:yamingd,项目名称:argo,代码行数:24,代码来源:ElasticSearchTemplate.java
示例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);
}
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:11,代码来源:PerfTestNumerify_AllTypes_Base.java
示例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);
}
}
开发者ID:dfci-cccb,项目名称:mev,代码行数:11,代码来源:PerfTestNumerify_Touch_Base.java
示例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();
}
开发者ID:alien4cloud,项目名称:elasticsearch-mapping-parent,代码行数:10,代码来源:QueryHelper.java
示例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);
}
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:AbstractClient.java
示例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();
}
开发者ID:ezbake,项目名称:ezelastic,代码行数:42,代码来源:ElasticClient.java
示例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();
}
开发者ID:atlasapi,项目名称:atlas-deer,代码行数:6,代码来源:EsContentSearcherV3CompatibilityTest.java
示例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);
开发者ID:baidu,项目名称:Elasticsearch,代码行数:7,代码来源:Client.java
注:本文中的org.elasticsearch.action.count.CountRequestBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论