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

io.searchbox.core.DeleteByQuery 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;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
 * Delete By Query API  is removed in Elasticsearch version 2.0.
 * You need to install the plugin with the same name for this action to work.
 *
 * @author Dogukan Sonmez
 * @author cihat keser
 * @see Delete By Query is now a plugin
 */
public class DeleteByQuery extends GenericResultAbstractAction {

    protected DeleteByQuery(Builder builder) {
        super(builder);

        this.payload = builder.query;
        setURI(buildURI());
    }

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

    @Override
    public String getPathToResult() {
        return "ok";
    }

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

    @Override
    public int hashCode() {
        return new HashCodeBuilder()
                .appendSuper(super.hashCode())
                .toHashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (obj.getClass() != getClass()) {
            return false;
        }

        return new EqualsBuilder()
                .appendSuper(super.equals(obj))
                .isEquals();
    }

    public static class Builder extends AbstractMultiTypeActionBuilder {

        private String query;

        public Builder(String query) {
            this.query = query;
        }

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

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy