Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountRequestBuilder


  @Override
  public Long getCount(String appid, String type) {
    if (StringUtils.isBlank(appid)) {
      return 0L;
    }
    CountRequestBuilder crb = client().prepareCount(stripRouting(appid)).
        setRouting(getRouting(appid, null)).
        setQuery(QueryBuilders.matchAllQuery());

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here


      for (Map.Entry<String, ?> term : terms.entrySet()) {
        ((AndFilterBuilder) fb).add(FilterBuilders.termFilter(term.getKey(), term.getValue()));
      }
    }
    QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), fb);
    CountRequestBuilder crb = client().prepareCount(stripRouting(appid)).
        setQuery(qb).setRouting(getRouting(appid, null));

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here

                                   Specification<Composite> whereClause,
                                   Map<String, Object> variables )
            throws EntityFinderException
        {
            // Prepare request
            CountRequestBuilder request = support.client().prepareCount( support.index() );

            AndFilterBuilder filterBuilder = baseFilters( resultType );
            QueryBuilder queryBuilder = processWhereSpecification( filterBuilder, whereClause, variables );

            request.setQuery( filteredQuery( queryBuilder, filterBuilder ) );

            // Log
            LOGGER.debug( "Will count Entities: {}", request );

            // Execute
            CountResponse count = request.execute().actionGet();

            return count.getCount();
        }
View Full Code Here

  @Override
  public Long getCount(String appid, String type) {
    if (StringUtils.isBlank(appid)) {
      return 0L;
    }
    CountRequestBuilder crb = client().prepareCount(stripRouting(appid)).
        setRouting(getRouting(appid, null)).
        setQuery(QueryBuilders.matchAllQuery());

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here

      for (Map.Entry<String, ?> term : terms.entrySet()) {
        ((AndFilterBuilder) fb).add(FilterBuilders.termFilter(term.getKey(), term.getValue()));
      }
    }
    QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), fb);
    CountRequestBuilder crb = client().prepareCount(stripRouting(appid)).
        setQuery(qb).setRouting(getRouting(appid, null));

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here

  @Override
  public Long getCount(String appid, String type) {
    if (StringUtils.isBlank(appid)) {
      return 0L;
    }
    CountRequestBuilder crb = client().prepareCount(appid).
        setQuery(QueryBuilders.matchAllQuery());

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here

      for (Map.Entry<String, ?> term : terms.entrySet()) {
        ((AndFilterBuilder) fb).add(FilterBuilders.termFilter(term.getKey(), term.getValue()));
      }
    }
    QueryBuilder qb = QueryBuilders.filteredQuery(QueryBuilders.matchAllQuery(), fb);
    CountRequestBuilder crb = client().prepareCount(appid).setQuery(qb);

    if (type != null) {
      crb.setTypes(type);
    }

    return crb.execute().actionGet().getCount();
  }
View Full Code Here

    public ListenableActionFuture<CountResponse> execute(Client client, String indexName, OperationContext helper) {
      final TypeMapping typeMapping = helper.findTypeMapping(_type);

      final String type = typeMapping.getTypeAlias();

      CountRequestBuilder builder = client.prepareCount(indexName).setTypes(type).setQuery(_query);

      return builder.execute();
    }
View Full Code Here

    String indexName[] = isNotEmpty(query.getIndices()) ? query.getIndices().toArray(new String[query.getIndices().size()]) : retrieveIndexNameFromPersistentEntity(clazz);
    String types[] = isNotEmpty(query.getTypes()) ? query.getTypes().toArray(new String[query.getTypes().size()]) : retrieveTypeFromPersistentEntity(clazz);

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

    CountRequestBuilder countRequestBuilder = client.prepareCount(indexName);

    if (types != null) {
      countRequestBuilder.setTypes(types);
    }
    return countRequestBuilder;
  }
View Full Code Here

    }
  }

  @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());
  }
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.count.CountRequestBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.