Codota Logo
CountResponse
Code IndexAdd Codota to your IDE (free)

How to use
CountResponse
in
org.elasticsearch.action.count

Best Java code snippets using org.elasticsearch.action.count.CountResponse (Showing top 20 results out of 315)

Refine searchRefine arrow

  • CountRequestBuilder
  • Client
  • Common ways to obtain CountResponse
private void myMethod () {
CountResponse c =
  • Codota IconClient client;client.prepareCount().execute().actionGet()
  • Smart code suggestions by Codota
}
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: sirensolutions/siren-join

public void setupIndex() {
  log("==== INDEX SETUP ====");
  try {
    client.admin().indices().create(createIndexRequest(PARENT_INDEX)).actionGet();
    client.admin().indices().create(createIndexRequest(CHILD_INDEX)).actionGet();
    Thread.sleep(5000);
    int counter = 0;
    for (; i <= ITERS; i++) {
      BulkRequestBuilder request = client.prepareBulk();
      for (int j = 0; j < BATCH_SIZE; j++) {
        String parentId = Integer.toString(counter);
  client.admin().indices().prepareRefresh().execute().actionGet();
  log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
  log("");
origin: karussell/elasticsearch-reindex

if(client.admin().indices().exists(new IndicesExistsRequest(newIndexName)).actionGet().isExists()) {
  logger.info("target index already exists, skip creation: " + newIndexName);
IndexMetaData indexData = client.admin().cluster().state(new ClusterStateRequest()).
    actionGet().getState().metaData().indices().get(searchIndexName);
Settings searchIndexSettings = indexData.settings();
client.admin().indices().refresh(new RefreshRequest(newIndexName)).actionGet();
long oldCount = client.count(new CountRequest(searchIndexName)).actionGet().getCount();
long newCount = client.count(new CountRequest(newIndexName)).actionGet().getCount();
if (oldCount == newCount) {
  logger.info("deleting " + searchIndexName);
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 SearchResponse search(String collectionName, QueryBuilder query) {
  final CountResponse count = count(collectionName, query);
  return getClient().prepareSearch().setTypes(collectionName)
      .setQuery(query)
      .setSize((int) count.getCount())
      .addFields("id")
      .execute()
      .actionGet(initTimeout);
}
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: 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();
}
origin: alien4cloud/alien4cloud

/**
 * Perform a count request based on the given class.
 *
 * @return The count response.
 */
public long count() {
  return super.count(indices, esTypes).getCount();
}
origin: harbby/presto-connectors

public RestStatus status() {
  return RestStatus.status(getSuccessfulShards(), getTotalShards(), getShardFailures());
}
origin: harbby/presto-connectors

  @Override
  protected CountResponse getDelegatedFromInstigator(SearchResponse response) {
    return new CountResponse(response);
  }
});
origin: sirensolutions/siren-join

public void setupIndex() {
  log("==== INDEX SETUP ====");
  try {
   client.admin().indices().create(createIndexRequest(PARENT_INDEX).mapping(PARENT_TYPE,
       "id", "type=string,index=not_analyzed,doc_values=true",
       "num", "type=integer,doc_values=true")).actionGet();
   client.admin().indices().create(createIndexRequest(CHILD_INDEX).mapping(CHILD_TYPE,
       "id", "type=string,index=not_analyzed,doc_values=true",
       "pid", "type=string,index=not_analyzed,doc_values=true",
    int counter = 0;
    for (; i <= ITERS; i++) {
      BulkRequestBuilder request = client.prepareBulk();
      for (int j = 0; j < BATCH_SIZE; j++) {
        String parentId = Integer.toString(counter);
  client.admin().indices().prepareRefresh().execute().actionGet();
  log("Number of docs in index: " + client.prepareCount(PARENT_INDEX, CHILD_INDEX).setQuery(matchAllQuery()).execute().actionGet().getCount());
  log("");
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: ru.yandex.qatools.embed/embedded-services

protected SearchResponse search(String collectionName, QueryBuilder query) {
  final CountResponse count = count(collectionName, query);
  return getClient().prepareSearch().setTypes(collectionName)
      .setQuery(query)
      .setSize((int) count.getCount())
      .addFields("id")
      .execute()
      .actionGet(initTimeout);
}
origin: com.lordofthejars/nosqlunit-elasticsearch2

  private static long numberOfInsertedDocuments(Client client) {
    final CountResponse numberOfElements = client.prepareCount().execute().actionGet();
    return numberOfElements.getCount();
  }
}
origin: javanna/elasticshell

  @Override
  protected XContentBuilder toXContent(CountRequest request, CountResponse response, XContentBuilder builder) throws IOException {
    builder.startObject();
    builder.field(Fields.COUNT, response.getCount());
    buildBroadcastShardsHeader(builder, response);
    builder.endObject();
    return builder;
  }
}
origin: harbby/presto-connectors

  @Override
  protected CountResponse getDelegatedFromInstigator(SearchResponse response) {
    return new CountResponse(response);
  }
});
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: lordofthejars/nosql-unit

private boolean isAnyIndexPresent() {
  CountResponse numberOfElements = client.prepareCount().execute().actionGet();
  return numberOfElements.getCount() > 0;
}
origin: harbby/presto-connectors

  @Override
  protected CountResponse convert(SearchResponse listenerResponse) {
    return new CountResponse(listenerResponse);
  }
};
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());
}
org.elasticsearch.action.countCountResponse

Javadoc

The response of the count action.

Most used methods

  • getCount
  • <init>
  • count
  • getShardFailures
  • getSuccessfulShards
  • getTotalShards

Popular in Java

  • Making http post requests using okhttp
  • getExternalFilesDir (Context)
  • getContentResolver (Context)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Manifest (java.util.jar)
    The Manifest class is used to obtain attribute information for a JarFile and its entries.
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now