All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.searchbox.core.SearchShards Maven / Gradle / Ivy

There is a newer version: 6.3.1
Show newest version
package io.searchbox.core;

import io.searchbox.action.AbstractMultiTypeActionBuilder;
import io.searchbox.action.GenericResultAbstractAction;

/**
 * The search shards api returns the indices and shards that a search request would be executed against.
 * This can give useful feedback for working out issues or planning optimizations with routing and shard preferences.
 *
 * @author cihat keser
 */
public class SearchShards extends GenericResultAbstractAction {

    protected SearchShards(Builder builder) {
        super(builder);
        setURI(buildURI());
    }

    @Override
    protected String buildURI() {
        return super.buildURI() + "/_search_shards";
    }

    @Override
    public String getRestMethodName() {
        return "GET";
    }

    public static class Builder extends AbstractMultiTypeActionBuilder {

        /**
         *
         * @param routing A comma-separated list of routing values to take into account when
         *                determining which shards a request would be executed against.
         */
        public Builder routing(String routing) {
            setParameter("routing", routing);
            return this;
        }

        /**
         *
         * @param preference Controls a preference of which shard replicas to execute the search request on.
         *                   By default, the operation is randomized between the shard replicas. See the
         *                   preference documentation
         *                   for a list of all acceptable values.
         */
        public Builder preference(String preference) {
            setParameter("preference", preference);
            return this;
        }

        /**
         *
         * @param local A boolean value whether to read the cluster state locally in order to determine
         *              where shards are allocated instead of using the Master node’s cluster state.
         */
        public Builder local(Boolean local) {
            setParameter("local", local);
            return this;
        }

        @Override
        public SearchShards build() {
            return new SearchShards(this);
        }
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy