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

com.basho.riak.client.api.commands.mapreduce.SearchMapReduce Maven / Gradle / Ivy

There is a newer version: 2.1.1
Show newest version
package com.basho.riak.client.api.commands.mapreduce;

/**
 * Command used to perform a map reduce operation with a search query as input.
 * @author Dave Rusek 
 * @since 2.0
 */
public class SearchMapReduce extends MapReduce
{
	protected SearchMapReduce(SearchInput input, Builder builder)
	{
		super(input, builder);
	}

    /**
     * Builder for a SearchMapReduce command.
     */
	public static class Builder extends MapReduce.Builder
	{

		private String index;
		private String query;

		@Override
		protected Builder self()
		{
			return this;
		}

        /**
         * Set the index to search.
         * @param index The index to run the search on
         * @return a reference to this object.
         */
		public Builder withIndex(String index)
		{
			this.index = index;
			return this;
		}

        /**
         * Set the query to run.
         * @param query The query to run
         * @return a reference to this object.
         */
		public Builder withQuery(String query)
		{
			this.query = query;
			return this;
		}

        /**
         * Construct a new SearchMapReduce operation.
         * @return the new SearchMapReduce operation.
         */
		public SearchMapReduce build()
		{
			if (index == null)
			{
				throw new IllegalStateException("An index must be specified");
			}

			if (query == null)
			{
				throw new IllegalStateException("A query must be specified");
			}

			return new SearchMapReduce(new SearchInput(index, query), this);
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy