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

org.lumongo.client.command.ClearIndex Maven / Gradle / Ivy

There is a newer version: 0.52
Show newest version
package org.lumongo.client.command;

import com.google.protobuf.RpcController;
import com.google.protobuf.ServiceException;
import org.lumongo.client.command.base.SimpleCommand;
import org.lumongo.client.pool.LumongoConnection;
import org.lumongo.client.result.ClearIndexResult;
import org.lumongo.cluster.message.Lumongo.ClearRequest;
import org.lumongo.cluster.message.Lumongo.ClearResponse;
import org.lumongo.cluster.message.Lumongo.ExternalService;

/**
 * Removes all documents from a given index
 * @author mdavis
 *
 */
public class ClearIndex extends SimpleCommand {

	private String indexName;

	public ClearIndex(String indexName) {
		this.indexName = indexName;
	}

	@Override
	public ClearRequest getRequest() {
		return ClearRequest.newBuilder().setIndexName(indexName).build();
	}

	@Override
	public ClearIndexResult execute(LumongoConnection lumongoConnection) throws ServiceException {
		ExternalService.BlockingInterface service = lumongoConnection.getService();
		RpcController controller = lumongoConnection.getController();

		ClearResponse clearResponse = service.clear(controller, getRequest());

		return new ClearIndexResult(clearResponse);
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy