Package org.elasticsearch.action.admin.indices.optimize

Examples of org.elasticsearch.action.admin.indices.optimize.OptimizeRequest


                .execute().actionGet().isAcknowledged();
    }

    public void optimizeIndex(String index) {
        // http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize/
        OptimizeRequest or = new OptimizeRequest(index);

        or.maxNumSegments(configuration.getIndexOptimizationMaxNumSegments());
        or.onlyExpungeDeletes(false);
        or.flush(true);
        or.waitForMerge(true); // This makes us block until the operation finished.

        c.admin().indices().optimize(or).actionGet();
    }
View Full Code Here


     * @param indices The indices to optimize. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
     * @return The optimize request
     * @see org.elasticsearch.client.IndicesAdminClient#optimize(org.elasticsearch.action.admin.indices.optimize.OptimizeRequest)
     */
    public static OptimizeRequest optimizeRequest(String... indices) {
        return new OptimizeRequest(indices);
    }
View Full Code Here

* @author kimchy (shay.banon)
*/
public class OptimizeRequestBuilder extends BaseIndicesRequestBuilder<OptimizeRequest, OptimizeResponse> {

    public OptimizeRequestBuilder(IndicesAdminClient indicesClient) {
        super(indicesClient, new OptimizeRequest());
    }
View Full Code Here

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

    @Override public void handleRequest(final RestRequest request, final RestChannel channel) {
        OptimizeRequest optimizeRequest = new OptimizeRequest(RestActions.splitIndices(request.param("index")));
        try {
            optimizeRequest.waitForMerge(request.paramAsBoolean("wait_for_merge", optimizeRequest.waitForMerge()));
            optimizeRequest.maxNumSegments(request.paramAsInt("max_num_segments", optimizeRequest.maxNumSegments()));
            optimizeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", optimizeRequest.onlyExpungeDeletes()));
            optimizeRequest.flush(request.paramAsBoolean("flush", optimizeRequest.flush()));
            optimizeRequest.refresh(request.paramAsBoolean("refresh", optimizeRequest.refresh()));

            // we just send back a response, no need to fork a listener
            optimizeRequest.listenerThreaded(false);
            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.THREAD_PER_SHARD;
            }
            optimizeRequest.operationThreading(operationThreading);
        } 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 OptimizeRequestBuilder<JsonInput, JsonOutput> extends AbstractRequestBuilderJsonOutput<OptimizeRequest, OptimizeResponse, JsonInput, JsonOutput> {

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

                actionGet();
        refresh();
    }

    public OptimizeResponse optimize(int optimizeToSegmentsAfterUpdate) {
        return client.admin().indices().optimize(new OptimizeRequest(getIndexName()).maxNumSegments(optimizeToSegmentsAfterUpdate)).actionGet();
    }
View Full Code Here

    public OptimizeResponse optimize() {
        return optimize(getIndexName(), 1);
    }

    public OptimizeResponse optimize(String indexName, int optimizeToSegmentsAfterUpdate) {
        return client.admin().indices().optimize(new OptimizeRequest(indexName).maxNumSegments(optimizeToSegmentsAfterUpdate)).actionGet();
    }
View Full Code Here

                stringIDs[j] = String.valueOf(ids[j]);
            }
            putBulk(stringIDs, ids, timestamps);
        }
        client().admin().indices().optimize(
                new OptimizeRequest().waitForMerge(true));
        return itemsPerDay;
    }
View Full Code Here

     * @param indices The indices to optimize. Use <tt>null</tt> or <tt>_all</tt> to execute against all indices
     * @return The optimize request
     * @see org.elasticsearch.client.IndicesAdminClient#optimize(org.elasticsearch.action.admin.indices.optimize.OptimizeRequest)
     */
    public static OptimizeRequest optimizeRequest(String... indices) {
        return new OptimizeRequest(indices);
    }
View Full Code Here

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

    @Override
    public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
        OptimizeRequest optimizeRequest = new OptimizeRequest(Strings.splitStringByCommaToArray(request.param("index")));
        optimizeRequest.listenerThreaded(false);
        optimizeRequest.indicesOptions(IndicesOptions.fromRequest(request, optimizeRequest.indicesOptions()));
        optimizeRequest.waitForMerge(request.paramAsBoolean("wait_for_merge", optimizeRequest.waitForMerge()));
        optimizeRequest.maxNumSegments(request.paramAsInt("max_num_segments", optimizeRequest.maxNumSegments()));
        optimizeRequest.onlyExpungeDeletes(request.paramAsBoolean("only_expunge_deletes", optimizeRequest.onlyExpungeDeletes()));
        optimizeRequest.flush(request.paramAsBoolean("flush", optimizeRequest.flush()));
        client.admin().indices().optimize(optimizeRequest, new RestBuilderListener<OptimizeResponse>(channel) {
            @Override
            public RestResponse buildResponse(OptimizeResponse response, XContentBuilder builder) throws Exception {
                builder.startObject();
                buildBroadcastShardsHeader(builder, response);
View Full Code Here

TOP

Related Classes of org.elasticsearch.action.admin.indices.optimize.OptimizeRequest

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.