My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Running and debugging elasticsearch source code in IntelliJ IDEA

escoder's photo
escoder
·Jun 6, 2021·

2 min read

Setup and Run Elasticsearch source code

  1. 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
    
  2. 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 here

  3. Set JAVA_PATH for the elasticsearch directory using this command

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
    
  4. 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.

  5. Once the path is set, the next step is to import the project.

  6. For importing the project in Intellij, select File -> Open, and then go to the build.gradle file

  7. In the Project structure, add SDK of Java 15, for the project and name it as "15"

  8. After complete indexing is done, open the terminal tab in IntelliJ

  9. Check the java version using java --version, this should also point to Java 15 java-version.jpeg

  10. And then run the command ./gradlew :run

  11. After the source code is built completely, run localhost:9200 on the browser. The current version of elasticsearch has username: elastic and password: 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

config.jpeg

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