public Long countByQualityProfileKey(QualityProfileKey key) {
   CountRequestBuilder request =
       getClient()
           .prepareCount(getIndexName())
           .setQuery(
               QueryBuilders.termQuery(
                   ActiveRuleNormalizer.ActiveRuleField.PROFILE_KEY.field(), key.toString()))
           .setRouting(key.toString());
   return request.get().getCount();
 }
Beispiel #2
0
 @Override
 public IndexStat getIndexStat() {
   CountRequestBuilder countRequest =
       client
           .prepareCount(this.getIndexName())
           .setTypes(this.getIndexType())
           .setQuery(QueryBuilders.matchAllQuery());
   CountResponse response = countRequest.get();
   return new IndexStat(getLastSynchronization(), response.getCount());
 }
Beispiel #3
0
 // ===================================================================================
 //                                                                               Build
 //                                                                               =====
 @Override
 public CountRequestBuilder build(CountRequestBuilder builder) {
   if (_conditionQuery != null) {
     QueryBuilder queryBuilder = _conditionQuery.getQuery();
     if (queryBuilder != null) {
       builder.setQuery(queryBuilder);
     }
   }
   return builder;
 }
  @Override
  public <T> long count(SearchQuery searchQuery, Class<T> clazz) {
    String indexName[] =
        isNotEmpty(searchQuery.getIndices())
            ? searchQuery.getIndices().toArray(new String[searchQuery.getIndices().size()])
            : retrieveIndexNameFromPersistentEntity(clazz);
    String types[] =
        isNotEmpty(searchQuery.getTypes())
            ? searchQuery.getTypes().toArray(new String[searchQuery.getTypes().size()])
            : retrieveTypeFromPersistentEntity(clazz);

    Assert.notNull(indexName, "No index defined for Query");

    CountRequestBuilder countRequestBuilder = client.prepareCount(indexName);

    if (types != null) {
      countRequestBuilder.setTypes(types);
    }
    if (searchQuery.getQuery() != null) {
      countRequestBuilder.setQuery(searchQuery.getQuery());
    }
    return countRequestBuilder.execute().actionGet().getCount();
  }