Scripting in java

Hi,

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 {
@Override
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();
doc().field(afield);
}

@Override
public Object run(){
return(null);
}
}

javac -cp ./elasticsearch-1.0.1/lib/elasticsearch-1.0.1.jar
scripting/ex2/*.java
scripting/ex2/Ex2Script.java:28: cannot find symbol
symbol : method field(java.lang.String)
location: class org.elasticsearch.search.lookup.DocLookup
doc().field(afield);

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 elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/b888da10-631c-4d06-9f9a-1f2f2f0116d6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.