Running and debugging elasticsearch source code in IntelliJ IDEA
Setup and Run Elasticsearch source code
Download elasticsearch source code from Github. You need to clone the Elasticsearch repository using the below command
git clone https://github.com/elastic/elasticsearch.git
The current version of elasticsearch (i.e
7.13
), builds only on Java 15. You'll need to ensure that Java 15 is installed in your system, and if it is not installed, install it from hereSet
JAVA_PATH
for the elasticsearch directory using this commandexport JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
You can check whether the path is correctly set or not using
echo $JAVA_PATH
This command should return the complete path directory of Java 15.Once the path is set, the next step is to import the project.
For importing the project in Intellij, select
File -> Open
, and then go to thebuild.gradle
fileIn the Project structure, add SDK of
Java 15
, for the project and name it as"15"
After complete indexing is done, open the terminal tab in IntelliJ
Check the java version using
java --version
, this should also point to Java 15And then run the command
./gradlew :run
After the source code is built completely, run
localhost:9200
on the browser. The current version of elasticsearch hasusername: elastic
andpassword: password
To know more about how to set up and run the source code, refer to this part of CONTIBUTING.md
The steps written above are for Elasticsearch version 7.13 and tested on IntelliJ IDEA 2021.1 (Community Edition)
Debug Elasticsearch source code
If you have followed the steps, as given above, to import the elasticsearch source code, then a configuration named "Debug Elasticsearch"
, will be automatically created along with proper configurations.
Otherwise set the configurations as shown below
Remember that you need to launch the IntelliJ debug run configuration before running the :run task.
To know more about how to launch and debug the source code, refer to this part of documentation