Scripting in java


I'm trying to play with scripting (in java) and that's not obvious to me

1/ The smallest example don't compile due to doc().field not found

public class Ex2ScriptFactory implements NativeScriptFactory {
public ExecutableScript newScript (@Nullable Map<String,Object> params) {
return new Ex2Script(params);

public class Ex2Script extends AbstractSearchScript {
public Ex2Script(@Nullable Map<String,Object> params) {
String afield = (String)params.get("field");
DocLookup docLookup=doc();

public Object run(){

javac -cp ./elasticsearch-1.0.1/lib/elasticsearch-1.0.1.jar
scripting/ex2/ cannot find symbol
symbol : method field(java.lang.String)
location: class

It the same with e.g. doc().numeric(...)

Do I miss something ?

2/ More 'high level' question
giving a set of documents (events), I'd like to iterate over them to
compute values and provide new fields
Is this acceptable in elasticsearch, is scripting available for that ?
(for example to compute the duration between two events)

Best regards

You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit
For more options, visit