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; }
private static long numberOfInsertedDocuments(Client client) { final CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount(); } }
@Override public Long execute(Client client) throws ElasticsearchException { CountResponse response = client.prepareCount(indices).execute().actionGet(); return response.getCount(); }
private static final long numberOfInsertedDocuments(Client client) { CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount(); }
private static long numberOfInsertedDocuments(Client client) { final CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount(); } }
private boolean isAnyIndexPresent() { CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount() > 0; }
private static long numberOfInsertedDocuments(Client client) { final CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount(); } }
@Override public Long execute(Client client) throws ElasticsearchException { CountResponse response = client.prepareCount(indices).execute().actionGet(); return response.getCount(); }
private boolean isAnyIndexPresent() { CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount() > 0; }
private boolean isAnyIndexPresent() { CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount() > 0; }
private static final long numberOfInsertedDocuments(Client client) { CountResponse numberOfElements = client.prepareCount().execute().actionGet(); return numberOfElements.getCount(); }
protected CountResponse count(String collectionName, QueryBuilder query) { return getClient().prepareCount() .setTypes(collectionName) .setQuery(query) .execute() .actionGet(initTimeout); }
@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; } }
protected CountResponse count(String collectionName, QueryBuilder query) { return getClient().prepareCount() .setTypes(collectionName) .setQuery(query) .execute() .actionGet(initTimeout); }
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(); }
public int size() { MatchAllQueryBuilder query = QueryBuilders.matchAllQuery(); CountResponse response = client.prepareCount(index).setTypes(type).setQuery(query).execute().actionGet(); return MathUtil.longToInt(response.getCount()); }
@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(); }
@Override public int getNDocs() { assureIndex(); CountResponse response = client.prepareCount(indexName) .setQuery(filteredQuery(matchAllQuery(),termFilter(SearchService.FIELD_INDEXED, true))) .execute() .actionGet(); return (int) response.getCount(); }
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()); }
@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(); }