How Debug custom elasticsearch8.14 plugin in Intellij

Hello everyone, I am an elasticsearch developer. Due to business needs, I need to develop a plug-in. The logic of this plug-in is relatively complex. I need the degbug plug-in source code. I can debug the plug-in locally in elasticsearch6.8 through the following code,

public class EmbeddedNode extends Node {

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

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

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

    public Version getVersion() {
        return version;
    }

    @Override
    protected void registerDerivedNodeNameWithLogger(String nodeName) {

    }
}

Modify the startup class and load the custom plug-in org.elasticsearch.bootstrap.Bootstrap

//  Line 227 ExamplePlugin is the main class of the custom plugin
        Collection plugins = new ArrayList<>();
        Collections.addAll(plugins, ExamplePlugin.class);
        node = new EmbeddedNode(environment, Version.CURRENT, plugins) {
            @Override
            protected void validateNodeBeforeAcceptingRequests(
                final BootstrapContext context,
                final BoundTransportAddress boundTransportAddress, List<BootstrapCheck> checks) throws NodeValidationException {
                BootstrapChecks.check(context, boundTransportAddress, checks);
            }
        };

But in elasticsearch8.14, I can't find any way to degbug the plugin source code locally. Please help me. Thank you very much.

From Elastic Search to Elasticsearch

Removed elastic-app-search

Can someone help me take a look?

I actually just want to know how to debug the elasticsearch plugin I developed myself

@nik9000
Hello, I saw you answered a related question before, but that was a long time ago, so I would like to ask you how to deg the plugin in elasticsearch 8.14

@DavidTurner
Could you please take a look at this issue?

I think that you need to run the plugin within an elasticsearch Node and then attach your debugger to the JVM.

Otherwise, I'd recommend may be writing some YAML Rest tests, like
Creating text analysis plugins with the stable plugin API | Elasticsearch Plugins and Integrations [8.14] | Elastic

Finally may be look at elasticsearch/plugins/examples at main · elastic/elasticsearch · GitHub if you need some help about designing plugins.

Not sure it helps though.

Thanks for your reply. I found two other ways to debug local source code.
I created a submodules in the modules directory, and then copied all the classes of the plugins I developed to the modules, and then modified build.gradle

esplugin {
name 'rest-handler'
description 'An example plugin showing how to register a REST handler'
classname 'your own plugin path'
licenseFile rootProject.file('SSPL-1.0+ELASTIC-LICENSE-2.0.txt')
noticeFile rootProject.file('NOTICE.txt')
}

In this way, I can debug the source code of the plugin I developed myself. Although it is very laborious, I can finally debug it happily.

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