Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountRequest


        this.c = node.client();
        this.deflector = deflector;
    }

    public long total() {
        return c.count(new CountRequest(deflector.getAllDeflectorIndexNames())).actionGet().getCount();
    }
View Full Code Here


        return isr.actionGet().getIndices();
    }

    public long getTotalNumberOfMessages() {
        return c.count(new CountRequest(allIndicesAlias())).actionGet().getCount();
    }
View Full Code Here

     * @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)
     */
    public static CountRequest countRequest(String... indices) {
        return new CountRequest(indices);
    }
View Full Code Here

* @author kimchy (shay.banon)
*/
public class CountRequestBuilder extends BaseRequestBuilder<CountRequest, CountResponse> {

    public CountRequestBuilder(Client client) {
        super(client, new CountRequest());
    }
View Full Code Here

        controller.registerHandler(POST, "/{index}/{type}/_count", this);
        controller.registerHandler(GET, "/{index}/{type}/_count", this);
    }

    @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
        CountRequest countRequest = new CountRequest(RestActions.splitIndices(request.param("index")));
        // we just send back a response, no need to fork a listener
        countRequest.listenerThreaded(false);
        try {
            BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operation_threading"), BroadcastOperationThreading.SINGLE_THREAD);
            if (operationThreading == BroadcastOperationThreading.NO_THREADS) {
                // since we don't spawn, don't allow no_threads, but change it to a single thread
                operationThreading = BroadcastOperationThreading.SINGLE_THREAD;
            }
            countRequest.operationThreading(operationThreading);
            if (request.hasContent()) {
                countRequest.query(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), true);
            } else {
                String source = request.param("source");
                if (source != null) {
                    countRequest.query(source);
                } else {
                    countRequest.query(RestActions.parseQuerySource(request));
                }
            }
            countRequest.queryHint(request.param("query_hint"));
            countRequest.routing(request.param("routing"));
            countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
            countRequest.types(splitTypes(request.param("type")));
        } catch (Exception e) {
            try {
                XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
View Full Code Here

        controller.registerHandler(POST, "/{index}/{type}/_count", this);
        controller.registerHandler(GET, "/{index}/{type}/_count", this);
    }

    @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
        CountRequest countRequest = new CountRequest(RestActions.splitIndices(request.param("index")));
        // we just send back a response, no need to fork a listener
        countRequest.listenerThreaded(false);
        try {
            BroadcastOperationThreading operationThreading = BroadcastOperationThreading.fromString(request.param("operation_threading"), BroadcastOperationThreading.SINGLE_THREAD);
            if (operationThreading == BroadcastOperationThreading.NO_THREADS) {
                // since we don't spawn, don't allow no_threads, but change it to a single thread
                operationThreading = BroadcastOperationThreading.SINGLE_THREAD;
            }
            countRequest.operationThreading(operationThreading);
            if (request.hasContent()) {
                countRequest.query(request.contentByteArray(), request.contentByteArrayOffset(), request.contentLength(), true);
            } else {
                String source = request.param("source");
                if (source != null) {
                    countRequest.query(source);
                } else {
                    countRequest.query(RestActions.parseQuerySource(request));
                }
            }
            countRequest.queryHint(request.param("query_hint"));
            countRequest.routing(request.param("routing"));
            countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
            countRequest.types(splitTypes(request.param("type")));
        } catch (Exception e) {
            try {
                XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
                channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
            } catch (IOException e1) {
View Full Code Here

*/
@SuppressWarnings("unused")
public class CountRequestBuilder<JsonInput, JsonOutput> extends AbstractRequestBuilderJsonOutput<CountRequest, CountResponse, JsonInput, JsonOutput> {

    public CountRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
        super(client, new CountRequest(), jsonToString, stringToJson);
    }
View Full Code Here

    private void refresh(String index) {
        client.admin().indices().refresh(new RefreshRequest(index)).actionGet();
    }

    private long count(String index) {
        return client.count(new CountRequest(index)).actionGet().getCount();
    }
View Full Code Here

                // make sure to refresh the index here
                // (e.g. the index may be paused or refreshing with a very long interval):
                logger.info("refreshing " + searchIndexName);
                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);
                    client.admin().indices().delete(new DeleteIndexRequest(searchIndexName)).actionGet();
                }
            }
View Full Code Here

    this.saveDocuments();
    this.documentCount = 0;
  }

  public long count() {
    return this.esClient.count(new CountRequest(indexName).types(indexType)).actionGet().getCount();
  }
View Full Code Here

TOP

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

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.