Tabnine Logo
CountResponse.getCount
Code IndexAdd Tabnine to your IDE (free)

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

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

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: 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: 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: com.github.tlrx/elasticsearch-test

@Override
public Long execute(Client client) throws ElasticsearchException {
  CountResponse response = client.prepareCount(indices).execute().actionGet();
  return response.getCount();
}
origin: lordofthejars/nosql-unit

private boolean isAnyIndexPresent() {
  CountResponse numberOfElements = client.prepareCount().execute().actionGet();
  return numberOfElements.getCount() > 0;
}
origin: com.lordofthejars/nosqlunit-elasticsearch2

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

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

private static final long numberOfInsertedDocuments(Client client) {
  CountResponse numberOfElements = client.prepareCount().execute().actionGet();
  return numberOfElements.getCount();
}
origin: com.github.joschi.nosqlunit/nosqlunit-elasticsearch2

private boolean isAnyIndexPresent() {
  CountResponse numberOfElements = client.prepareCount().execute().actionGet();
  return numberOfElements.getCount() > 0;
}
origin: com.github.joschi.nosqlunit/nosqlunit-elasticsearch2

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

@Override
public Long execute(Client client) throws ElasticsearchException {
  CountResponse response = client.prepareCount(indices).execute().actionGet();
  return response.getCount();
}
origin: com.lordofthejars/nosqlunit-elasticsearch

private static final long numberOfInsertedDocuments(Client client) {
  CountResponse numberOfElements = client.prepareCount().execute().actionGet();
  return numberOfElements.getCount();
}
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: Yorubaname/yorubaname-website

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();
}
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: org.sakaiproject.search.elasticsearch/elasticsearch-util

@Override
public int getNDocs() {
  assureIndex();
  CountResponse response = client.prepareCount(indexName)
      .setQuery(filteredQuery(matchAllQuery(),termFilter(SearchService.FIELD_INDEXED, true)))
      .execute()
      .actionGet();
  return (int) response.getCount();
}
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: 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());
}
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: 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);
}
org.elasticsearch.action.countCountResponsegetCount

Javadoc

The count of documents matching the query provided.

Popular methods of CountResponse

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

Popular in Java

  • Finding current android device location
  • runOnUiThread (Activity)
  • findViewById (Activity)
  • getSharedPreferences (Context)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • Reference (javax.naming)
  • Top plugins for Android Studio
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