本文整理了Java中org.elasticsearch.client.Client.prepareCount()
方法的一些代码示例,展示了Client.prepareCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Client.prepareCount()
方法的具体详情如下:
包路径:org.elasticsearch.client.Client
类名称:Client
方法名:prepareCount
[英]A count of all the documents matching a specific query.
[中]与特定查询匹配的所有文档的计数。
代码示例来源:origin: richardwilly98/elasticsearch-river-mongodb
public static long getIndexCount(Client client, MongoDBRiverDefinition definition) {
if (client.admin().indices().prepareExists(definition.getIndexName()).get().isExists()) {
if (definition.isImportAllCollections()) {
return client.prepareCount(definition.getIndexName()).execute().actionGet().getCount();
} else {
if (client.admin().indices().prepareTypesExists(definition.getIndexName()).setTypes(definition.getTypeName()).get()
.isExists()) {
return client.prepareCount(definition.getIndexName()).setTypes(definition.getTypeName()).get().getCount();
}
}
}
return 0;
}
代码示例来源:origin: lordofthejars/nosql-unit
private static long numberOfInsertedDocuments(Client client) {
final CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount();
}
}
代码示例来源:origin: com.github.tlrx/elasticsearch-test
@Override
public Long execute(Client client) throws ElasticsearchException {
CountResponse response = client.prepareCount(indices).execute().actionGet();
return response.getCount();
}
代码示例来源:origin: lordofthejars/nosql-unit
private static final long numberOfInsertedDocuments(Client client) {
CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount();
}
代码示例来源:origin: com.lordofthejars/nosqlunit-elasticsearch2
private static long numberOfInsertedDocuments(Client client) {
final CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount();
}
}
代码示例来源:origin: lordofthejars/nosql-unit
private boolean isAnyIndexPresent() {
CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount() > 0;
}
代码示例来源:origin: com.github.joschi.nosqlunit/nosqlunit-elasticsearch2
private static long numberOfInsertedDocuments(Client client) {
final CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount();
}
}
代码示例来源:origin: tlrx/elasticsearch-test
@Override
public Long execute(Client client) throws ElasticsearchException {
CountResponse response = client.prepareCount(indices).execute().actionGet();
return response.getCount();
}
代码示例来源:origin: lordofthejars/nosql-unit
private boolean isAnyIndexPresent() {
CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount() > 0;
}
代码示例来源:origin: com.github.joschi.nosqlunit/nosqlunit-elasticsearch2
private boolean isAnyIndexPresent() {
CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount() > 0;
}
代码示例来源:origin: com.lordofthejars/nosqlunit-elasticsearch
private static final long numberOfInsertedDocuments(Client client) {
CountResponse numberOfElements = client.prepareCount().execute().actionGet();
return numberOfElements.getCount();
}
代码示例来源:origin: ru.yandex.qatools.embed/embedded-services
protected CountResponse count(String collectionName, QueryBuilder query) {
return getClient().prepareCount()
.setTypes(collectionName)
.setQuery(query)
.execute()
.actionGet(initTimeout);
}
代码示例来源:origin: Yorubaname/yorubaname-website
@Override
public Integer getSearchableNames() {
try {
CountResponse response = client.prepareCount(esConfig.getIndexName())
.setQuery(matchAllQuery())
.execute()
.actionGet();
return Math.toIntExact(response.getCount());
} catch (Exception e) {
return 0;
}
}
代码示例来源:origin: yandex-qatools/embedded-services
protected CountResponse count(String collectionName, QueryBuilder query) {
return getClient().prepareCount()
.setTypes(collectionName)
.setQuery(query)
.execute()
.actionGet(initTimeout);
}
代码示例来源:origin: Yorubaname/yorubaname-website
private SearchResponse prefixFilterSearch(String nameQuery, boolean getAll) {
int resultSet = 20;
if (getAll) {
CountResponse countResponse = client.prepareCount(esConfig.getIndexName()).execute().actionGet();
resultSet = (int) countResponse.getCount();
}
return client.prepareSearch(esConfig.getIndexName())
.setPostFilter(FilterBuilders.prefixFilter("name", nameQuery.toLowerCase()))
.setSize(resultSet)
.execute()
.actionGet();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public int size() {
MatchAllQueryBuilder query = QueryBuilders.matchAllQuery();
CountResponse response = client.prepareCount(index).setTypes(type).setQuery(query).execute().actionGet();
return MathUtil.longToInt(response.getCount());
}
代码示例来源:origin: alien4cloud/alien4cloud
@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();
}
代码示例来源:origin: org.sakaiproject.search.elasticsearch/elasticsearch-util
@Override
public int getNDocs() {
assureIndex();
CountResponse response = client.prepareCount(indexName)
.setQuery(filteredQuery(matchAllQuery(),termFilter(SearchService.FIELD_INDEXED, true)))
.execute()
.actionGet();
return (int) response.getCount();
}
代码示例来源:origin: ujmp/universal-java-matrix-package
public int count(String string) {
QueryBuilder query = QueryBuilders.queryString(string).defaultOperator(Operator.AND);
CountResponse response = client.prepareCount(index).setTypes(type).setQuery(query).execute().actionGet();
return MathUtil.longToInt(response.getCount());
}
代码示例来源:origin: SpringDataElasticsearchDevs/spring-data-elasticsearch
@Override
public <T> long count(SearchQuery query, Class<T> clazz) {
ElasticsearchPersistentEntity<T> persistentEntity = getPersistentEntityFor(clazz);
CountRequestBuilder countRequestBuilder = client.prepareCount(persistentEntity.getIndexName())
.setTypes(persistentEntity.getIndexType());
if(query.getQuery() != null){
countRequestBuilder.setQuery(query.getQuery());
}
return countRequestBuilder.execute().actionGet().count();
}
内容来源于网络,如有侵权,请联系作者删除!