ES Native (Java) Script error

Hello,

I've been struggling with the Native (Java) script for some time now. I am writing custom score plugin and building with Maven. My java class looks like this

package org.elasticsearch.plugin.hw.customscore;

import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.elasticsearch.plugins.Plugin;
import org.elasticsearch.plugins.ScriptPlugin;
import org.elasticsearch.common.Nullable;
import org.elasticsearch.script.*;

public class HW_NativeScriptPlugin extends Plugin implements ScriptPlugin {

@Override
public List<NativeScriptFactory> getNativeScripts() {
    return Collections.singletonList(new HW_NativeScriptFactory());
}

public static class HW_NativeScriptFactory implements NativeScriptFactory {
    @Override
    public ExecutableScript newScript(@Nullable Map<String, Object> params) {
        return new HW_NativeScript();
    }
    @Override
    public boolean needsScores() {
        return false;
    }
    @Override
    public String getName() {
        return "HW_SCRIPT";
    }
}

public static class HW_NativeScript extends AbstractDoubleSearchScript {
    @Override
    public double runAsDouble() {
        double a = 1;
        double b = 2;
        return a * b;
    }
}

}

pom.xml ->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-    v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.elasticsearch.plugin.hirewand.customscore</groupId>
  <artifactId>NativeScriptPlugin</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>NativeScriptPlugin</name>
  <url>http://maven.apache.org</url>
  <properties>
    <jdk.version>1.8</jdk.version>
  </properties>
  <dependencies>
    <dependency>
      <groupId>org.elasticsearch</groupId>
      <artifactId>elasticsearch</artifactId>
      <version>5.2.1</version>
    </dependency>
   </dependencies>
</project>

plugin-descriptor.properties ->

description=Custom score script for peopleworld
version=0.1
name=NativeScriptPlugin
classname=org.elasticsearch.plugin.hw.customscore.NativeScriptPlugin
java.version=1.8
elasticsearch.version=5.2.1

I m getting the following error while building my project

[ERROR] E:\ESPlugin\NativeScriptPlugin\src\main\java\org\elasticsearch\plugin\hw\customscore\HW_NativeScriptPlugin.java:[16,40] error: incompatible types: List<HW_NativeScriptFactory> cannot be converted to List
[ERROR] -> [Help 1]

Can anybody point out what am i doing wrong here ?

Hey,

can you provide full error messages? Also is there a stack trace in the logs or the console when starting up? What content is in line 16 of the Plugin?

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.