Package org.elasticsearch.action.count

Examples of org.elasticsearch.action.count.CountRequest


    refresh(INDEX_NAME);

    // Assert
    ;
    assertTrue(client().admin().indices().exists(new IndicesExistsRequest(INDEX_NAME)).actionGet().isExists());
    assertEquals(777, client().count(new CountRequest(INDEX_NAME).types(ESEntityType.NODE.getIndiceName())).actionGet().getCount());
    assertEquals(57, client().count(new CountRequest(INDEX_NAME).types(ESEntityType.WAY.getIndiceName())).actionGet().getCount());
  }
View Full Code Here


            }
            indices = node.whereClause().partitions().toArray(new String[node.whereClause().partitions().size()]);
        } else {
            indices = new String[] { node.tableInfo().ident().name() };
        }
        request = new CountRequest(indices);
        listener = new CountResponseListener(result);
        try {
            request.source(queryBuilder.convert(node.whereClause()), false);
        } catch (IOException e) {
            result.setException(e);
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

    @Test
    public void testCount() {
        String countShardAction = CountAction.NAME + "[s]";
        interceptTransportActions(countShardAction);

        CountRequest countRequest = new CountRequest(randomIndicesOrAliases());
        internalCluster().clientNodeClient().count(countRequest).actionGet();

        clearInterceptedActions();
        assertSameIndices(countRequest, countShardAction);
    }
View Full Code Here

    }

    @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.count(countRequest, new RestResponseListener<CountResponse>(channel) {
            @Override
View Full Code Here

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

    @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()));
        countRequest.listenerThreaded(false);
        if (request.hasContent()) {
            countRequest.source(request.content(), request.contentUnsafe());
        } else {
            String source = request.param("source");
            if (source != null) {
                countRequest.source(source);
            } else {
                QuerySourceBuilder querySourceBuilder = RestActions.parseQuerySource(request);
                if (querySourceBuilder != null) {
                    countRequest.source(querySourceBuilder);
                }
            }
        }
        countRequest.routing(request.param("routing"));
        countRequest.minScore(request.paramAsFloat("min_score", DEFAULT_MIN_SCORE));
        countRequest.types(Strings.splitStringByCommaToArray(request.param("type")));
        countRequest.preference(request.param("preference"));

        final int terminateAfter = request.paramAsInt("terminate_after", DEFAULT_TERMINATE_AFTER);
        if (terminateAfter < 0) {
            throw new ElasticsearchIllegalArgumentException("terminateAfter must be > 0");
        } else if (terminateAfter > 0) {
            countRequest.terminateAfter(terminateAfter);
        }
        client.count(countRequest, new RestBuilderListener<CountResponse>(channel) {
            @Override
            public RestResponse buildResponse(CountResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
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.