Debug Elasticsearch with IntelliJ

How to config Program arguments in IntelliJ ?

I got this error when I try to run:

ERROR: the system property [es.path.conf] must be set

Running Elasticsearch through IntelliJ is not easy to do properly (e.g., the modules will not be there without significant effort). Instead, you should start Elasticsearch from the command line and attach IntelliJ to the running instance. To do this:

  1. from the root of the repository, run gradle :distribution:tar:assemble
  2. untar the distribution from distribution/tar/build/distributions somewhere on your filesystem (e.g.,tar xf distribution/tar/build/distributions/elasticsearch-7.0.0-alpha1-SNAPSHOT.tar.gz -C ~/elasticsearch) if you are building from master which is currently on 7.0.0-alpha1 and you want to untar to ~/elasticsearch)
  3. run Elasticsearch from the location that you exploded the tarball to with ES_JAVA_OPTS=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 bin/elasticsearch)
  4. attach IntelliJ to the running instance: Run -> Edit Configurations -> Click + -> Select Remote -> ensure that the port is set to 5005, name the configuration "localhost:5005" -> Click Apply; in the upper right-hand corner (assuming a default layout) is a dropdown from which you need to select the configuration "localhost:5005" and click the bug icon to the right of it

Now Elasticsearch will start running and you can set breakpoints etc.

1 Like

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

After downloading Elasticsearch from github, in the top level directory there is file called CONTRIBUTING.md which describes how to configure your IDE, and there is also a file called TESTING.asciidoc which describes how to debug.

Based on the instructions contained in those text files, I have written a blog post that gives step-by-step instructions on how to configure IntelliJ IDEA to debug Elasticsearch and Lucene.

2 Likes

That's great. Thanks for sharing it with the community.