elastic / elasticsearch-mapper-attachments

Mapper Attachments Type plugin for Elasticsearch
https://www.elastic.co
Apache License 2.0
503 stars 94 forks source link

Plugin doesn't work with embedded elasticsearch in spring boot app's uber JAR #218

Closed bratislav closed 8 years ago

bratislav commented 8 years ago

Hi,

I'm running an embedded elasticsearch with attachment plugin inside one big spring-boot application ( as a stand-alone JAR). I have defined a contents field with the type = attachment and everything works fine when I run the app using mvn spring-boot:run command. If I build the final JAR using mvn clean install (or mvn package) and run it using java -jar this field will not get indexed at all! I have extended the Node class as follows :

public class NodeWithPlugins extends Node {

    private Version version;
    private Collection<Class<? extends Plugin>> plugins;

    public NodeWithPlugins(Environment environment, Version version, Collection<Class<? extends Plugin>> classpathPlugins) {
        super(environment, version, classpathPlugins);
        this.version = version;
        this.plugins = classpathPlugins;
      }

     public Collection<Class<? extends Plugin>> getPlugins() {
        return plugins;
    }

    public Version getVersion() {
      return version;
    }
}

...and I'm creating the node inside the @PostConstruct annotated method like this :

Collection plugins = new ArrayList<>();
        Collections.<Class<? extends Plugin>>addAll(plugins, MapperAttachmentsPlugin.class);
        node = new NodeWithPlugins(environment, Version.CURRENT, plugins);
        node.start();

My pom.xml has the following :

<!-- Elasticsearch -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch</artifactId>
    <version>2.3.3</version>
</dependency>

 <dependency>
    <groupId>org.elasticsearch.plugin</groupId>
    <artifactId>mapper-attachments</artifactId>
    <version>2.3.3</version>
 </dependency>

...and I can see that the mapper plugin gets embedded inside the final JAR (inside libs).

Am I missing something? Please advise.

dadoonet commented 8 years ago

This repo is used for elasticsearch < 2.0 only as stated in the README.

You should ask on discuss.elastic.co.