Providing parameters to AbstractSearchScript?

Quick question, I know that parameters are supported on in-line scripts as
documented here:

http://www.elasticsearch.org/guide/reference/query-dsl/script-filter.html

But is there a similar way to pass parameters into a Java-native
AbstractExecutableScript/AbstractSearchScript? For example:

public class CustomScript extends AbstractExecutableScript {

public CustomScript(@Nullable Map<String,Object> params){



}



@Override

public java.lang.Object run() {

  String param1 = // some code to grab a script/query parameter

}

}

--

The native script is created by a class that implements
NativeScriptFactory. So, you can do something like this:

public class CustomScript extends AbstractExecutableScript {

public static class CustomScriptNativeScriptFactory implements 

NativeScriptFactory {

    @Override
    public ExecutableScript newScript(@Nullable Map<String, Object> 

params) {
String param1 = params == null ? "default" :
XContentMapValues.nodeStringValue(params.get("param1"), "default");
return new CustomScript(param1);
}
}

private final param1;

public CustomScript(String param1){
    this.param1 = param1;
}

@Override
public java.lang.Object run() {
  // use this.myParam here
}

}

On Wednesday, January 16, 2013 11:49:04 PM UTC-5, Cedric Hurst wrote:

Quick question, I know that parameters are supported on in-line scripts as
documented here:

Elasticsearch Platform — Find real-time answers at scale | Elastic

But is there a similar way to pass parameters into a Java-native
AbstractExecutableScript/AbstractSearchScript? For example:

public class CustomScript extends AbstractExecutableScript {

public CustomScript(@Nullable Map<String,Object> params){



}



@Override

public java.lang.Object run() {

  String param1 = // some code to grab a script/query parameter

}

}

--