public CountRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) { super(client, new CountRequest(), jsonToString, stringToJson); }
public CountRequestBuilder(ElasticsearchClient client, CountAction action) { super(client, action, new CountRequest()); }
/** * Creates a count request which counts the hits matched against a query. Note, the query itself must be set * either using the JSON source of the query, or using a {@link org.elasticsearch.index.query.QueryBuilder} (using {@link org.elasticsearch.index.query.QueryBuilders}). * * @param indices The indices to count matched documents against a query. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices * @return The count request * @see org.elasticsearch.client.Client#count(org.elasticsearch.action.count.CountRequest) * @deprecated use {@link #searchRequest(String...)} instead and set size to 0 */ @Deprecated public static CountRequest countRequest(String... indices) { return new CountRequest(indices); }
@Override public void doRequest(final RestRequest request, final RestChannel channel, final Client client) { String[] indices = Strings.splitStringByCommaToArray(request.param("index")); CountRequest countRequest = new CountRequest(indices); String source = request.param("source"); if (source != null) { countRequest.source(source); } else { QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request); if (querySourceBuilder != null) { countRequest.source(querySourceBuilder); } } client.search(countRequest.toSearchRequest(), new RestResponseListener<SearchResponse>(channel) { @Override public RestResponse buildResponse(SearchResponse countResponse) throws Exception { return RestTable.buildResponse(buildTable(request, countResponse), channel); } }); }
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);
@Override public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) { CountRequest countRequest = new CountRequest(Strings.splitStringByCommaToArray(request.param("index"))); countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions())); if (RestActions.hasBodyContent(request)) {