Tabnine Logo
CountResponse
Code IndexAdd Tabnine 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
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

  • Creating JSON documents from java classes using gson
  • requestLocationUpdates (LocationManager)
  • getResourceAsStream (ClassLoader)
  • findViewById (Activity)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • ArrayList (java.util)
    ArrayList is an implementation of List, backed by an array. All optional operations including adding
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • JList (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now