diff --git a/src/main/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequest.java b/src/main/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequest.java
index c34c027412623..00bedbc8943d9 100644
--- a/src/main/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequest.java
+++ b/src/main/java/org/elasticsearch/action/indexedscripts/get/GetIndexedScriptRequest.java
@@ -19,9 +19,12 @@
package org.elasticsearch.action.indexedscripts.get;
+import org.elasticsearch.Version;
+import org.elasticsearch.action.ActionRequest;
import org.elasticsearch.action.ActionRequestValidationException;
+import org.elasticsearch.action.IndicesRequest;
import org.elasticsearch.action.ValidateActions;
-import org.elasticsearch.action.support.single.shard.SingleShardOperationRequest;
+import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
@@ -33,15 +36,12 @@
import java.io.IOException;
/**
- * A request to get a document (its source) from an index based on its type/language (optional) and id. Best created using
- * {@link org.elasticsearch.client.Requests#getRequest(String)}.
- *
- * The operation requires the {@link #index()}, {@link #scriptLang(String)} and {@link #id(String)}
- * to be set.
+ * A request to get an indexed script (its source) based on its language (optional) and id.
+ * The operation requires the {@link #scriptLang(String)} and {@link #id(String)} to be set.
*
* @see GetIndexedScriptResponse
*/
-public class GetIndexedScriptRequest extends SingleShardOperationRequest {
+public class GetIndexedScriptRequest extends ActionRequest implements IndicesRequest {
protected String scriptLang;
protected String id;
@@ -56,32 +56,28 @@ public class GetIndexedScriptRequest extends SingleShardOperationRequest_source
- * field will be returned.
- */
- public String[] fields() {
- return null;
- }
-
- /**
- * Sets the preference to execute the search. Defaults to randomize across shards. Can be set to
+ * Sets the preference to execute the get. Defaults to randomize across shards. Can be set to
* _local to prefer local shards, _primary to execute only on primary shards, or
* a custom value, which guarantees that the same order will be used across different requests.
*/
@@ -211,6 +204,10 @@ public VersionType versionType() {
@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
+ if (in.getVersion().before(Version.V_1_4_0)) {
+ //the index was previously serialized although not needed
+ in.readString();
+ }
scriptLang = in.readString();
id = in.readString();
preference = in.readOptionalString();
@@ -231,13 +228,17 @@ public void readFrom(StreamInput in) throws IOException {
@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
+ if (out.getVersion().before(Version.V_1_4_0)) {
+ //the index was previously serialized although not needed
+ out.writeString(ScriptService.SCRIPT_INDEX);
+ }
out.writeString(scriptLang);
out.writeString(id);
out.writeOptionalString(preference);
out.writeBoolean(refresh);
if (realtime == null) {
out.writeByte((byte) -1);
- } else if (realtime == false) {
+ } else if (!realtime) {
out.writeByte((byte) 0);
} else {
out.writeByte((byte) 1);
@@ -251,7 +252,6 @@ public void writeTo(StreamOutput out) throws IOException {
@Override
public String toString() {
- return "[" + index + "][" + scriptLang + "][" + id + "]: routing [" + routing + "]";
-
+ return "[" + ScriptService.SCRIPT_INDEX + "][" + scriptLang + "][" + id + "]: routing [" + routing + "]";
}
}
diff --git a/src/main/java/org/elasticsearch/rest/action/script/RestGetIndexedScriptAction.java b/src/main/java/org/elasticsearch/rest/action/script/RestGetIndexedScriptAction.java
index 1d383b49060b0..b1ce78cb25a66 100644
--- a/src/main/java/org/elasticsearch/rest/action/script/RestGetIndexedScriptAction.java
+++ b/src/main/java/org/elasticsearch/rest/action/script/RestGetIndexedScriptAction.java
@@ -19,8 +19,6 @@
package org.elasticsearch.rest.action.script;
import org.elasticsearch.ElasticsearchIllegalStateException;
-import org.elasticsearch.action.get.GetRequest;
-import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptRequest;
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse;
import org.elasticsearch.client.Client;
@@ -28,14 +26,11 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
-import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.action.support.RestResponseListener;
-import org.elasticsearch.script.ScriptService;
import java.io.IOException;
-import java.util.Map;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
@@ -47,8 +42,7 @@
public class RestGetIndexedScriptAction extends BaseRestHandler {
@Inject
- public RestGetIndexedScriptAction(Settings settings, Client client,
- ScriptService scriptService, RestController controller) {
+ public RestGetIndexedScriptAction(Settings settings, Client client, RestController controller) {
super(settings, client);
controller.registerHandler(GET, "/_scripts/{lang}/{id}", this);
}
@@ -56,7 +50,7 @@ public RestGetIndexedScriptAction(Settings settings, Client client,
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, Client client) {
- final GetIndexedScriptRequest getRequest = new GetIndexedScriptRequest(ScriptService.SCRIPT_INDEX, request.param("lang"), request.param("id"));
+ final GetIndexedScriptRequest getRequest = new GetIndexedScriptRequest(request.param("lang"), request.param("id"));
RestResponseListener responseListener = new RestResponseListener(channel) {
@Override
public RestResponse buildResponse(GetIndexedScriptResponse response) throws Exception {
diff --git a/src/main/java/org/elasticsearch/rest/action/template/RestGetSearchTemplateAction.java b/src/main/java/org/elasticsearch/rest/action/template/RestGetSearchTemplateAction.java
index d7c60061cef4c..326e5813104b8 100644
--- a/src/main/java/org/elasticsearch/rest/action/template/RestGetSearchTemplateAction.java
+++ b/src/main/java/org/elasticsearch/rest/action/template/RestGetSearchTemplateAction.java
@@ -19,21 +19,18 @@
package org.elasticsearch.rest.action.template;
import org.elasticsearch.ElasticsearchIllegalStateException;
-import org.elasticsearch.action.get.GetRequest;
-import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptRequest;
import org.elasticsearch.action.indexedscripts.get.GetIndexedScriptResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.xcontent.*;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+import org.elasticsearch.common.xcontent.XContentFactory;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.*;
import org.elasticsearch.rest.action.support.RestResponseListener;
-import org.elasticsearch.script.ScriptService;
-import org.elasticsearch.search.aggregations.support.ValuesSource;
import java.io.IOException;
-import java.util.Map;
import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestStatus.NOT_FOUND;
@@ -45,15 +42,14 @@
public class RestGetSearchTemplateAction extends BaseRestHandler {
@Inject
- public RestGetSearchTemplateAction(Settings settings, Client client,
- RestController controller, ScriptService scriptService) {
+ public RestGetSearchTemplateAction(Settings settings, Client client, RestController controller) {
super(settings, client);
controller.registerHandler(GET, "/_search/template/{id}", this);
}
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, Client client) {
- final GetIndexedScriptRequest getRequest = new GetIndexedScriptRequest(ScriptService.SCRIPT_INDEX, "mustache", request.param("id"));
+ final GetIndexedScriptRequest getRequest = new GetIndexedScriptRequest("mustache", request.param("id"));
RestResponseListener responseListener = new RestResponseListener(channel) {
@Override
public RestResponse buildResponse(GetIndexedScriptResponse response) throws Exception {