Script Engine with JAVA - elasticsearch-6.3.0

Thanks for your response ,

Previously i have used elasticsearch-5.1.1 , now i have tried to use script engine the code with 6.3.0 follows,

@Override
public ScriptEngine getScriptEngine(Settings settings, Collection<ScriptContext<?>> contexts) {
return new MyExpertScriptEngine();
}

/** An example {@link ScriptEngine} that uses Lucene segment details to implement pure document frequency scoring. */
// tag::expert_engine
private static class MyExpertScriptEngine implements ScriptEngine {
    
@Override
public String getType() {
    return "expert_scripts";
}

@Override
public <T> T compile(String scriptName, String scriptSource, ScriptContext<T> context, Map<String, String> params) {        
    
    log.info("Script name: "+scriptName);
    log.info("scriptSource "+scriptSource);
    
    log.info("SearchScript.CONTEXT "+SearchScript.CONTEXT);
    
    if (context.equals(SearchScript.CONTEXT) == false) {
        throw new IllegalArgumentException(getType() + " scripts cannot be used for context [" + context.name + "]");
    }
    // we use the script "source" as the script identifier
    if ("pure_df".equals(scriptSource)) {
        SearchScript.Factory factory = (p, lookup) -> new SearchScript.LeafFactory() {
            final String field;
            final String term;
            
            .... etc}

IS there any sample java api to pass the inputs to script engine.

  1. What we have to define in lang,If i am not wrong we have to provide native(Java)

  2. Instead of script.inline where we have to mention the source, hope that's also in elasticsearch.yml