{"id":150,"date":"2021-01-11T19:31:27","date_gmt":"2021-01-11T10:31:27","guid":{"rendered":"https:\/\/osmanthus.work\/?p=150"},"modified":"2021-03-09T08:50:49","modified_gmt":"2021-03-08T23:50:49","slug":"how-to-do-windows-debugging-elasticsearch-using-intellij-idea","status":"publish","type":"post","link":"https:\/\/osmanthus.work\/?p=150","title":{"rendered":"How to do windows debugging Elasticsearch using Intellij IDEA"},"content":{"rendered":"\n<!--more-->\n\n\n\n<p>ElasticSearch is implemented in Java language. So, we need build and debug tools in Java language. I show build and debug procedures using Java build tool Gradle and Java integrated development environment Intellij IDEA.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. Prerequisites<\/h2>\n\n\n\n<p>Version of Elasticsearch: Elasticsearch 7.10<\/p>\n\n\n\n<p>Target Machine and Host Machine: Windows10(same machine)<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Building Elasticsearch<\/h2>\n\n\n\n<p>Installi Gradle which is a Java build tool.<\/p>\n\n\n\n<p>(1) Install Oracle JDK11 from the following link<br><a href=\"https:\/\/www.oracle.com\/java\/technologies\/javase-downloads.html\">https:\/\/www.oracle.com\/java\/technologies\/javase-downloads.html<\/a><\/p>\n\n\n\n<p>(2) Install Gradle according to the following link procedures <br><a href=\"https:\/\/gradle.org\/install\/\">https:\/\/gradle.org\/install\/<\/a><\/p>\n\n\n\n<p>(3) Download ElasticSearch sources from the following link. Hereinafter we call the directory whch download to &lt;top&gt;.<br><a href=\"https:\/\/github.com\/elastic\/elasticsearch\">https:\/\/github.com\/elastic\/elasticsearch<\/a><\/p>\n\n\n\n<p>(4) Execute the following command to build Elasticsearch at commandline with working directory &lt;top&gt;<\/p>\n\n\n\n<p>gradlew.bat localDistro<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Debugging Elasticsearch<\/h2>\n\n\n\n<p>(1) Install Java integrated development environment IntelliJ IDEA community edition from the following link<\/p>\n\n\n\n<p><a href=\"https:\/\/www.jetbrains.com\/idea\/download\/#section=windows\">https:\/\/www.jetbrains.com\/idea\/download\/#section=windows<\/a><\/p>\n\n\n\n<p>(2) Open ElasticSsearch project using Intellij IDEA selecting &lt;top&gt;<\/p>\n\n\n\n<p>(3) Select [Run]&gt;[Debug Elasticsearch] in Intellij IDEA<\/p>\n\n\n\n<p>(4) Execute the following comannd at commandline with working directory &lt;top&gt;<\/p>\n\n\n\n<p>gradlew.bat run &#8211;debug-jvm<\/p>\n\n\n\n<p>(5) Install curl<\/p>\n\n\n\n<p>(6) Create a breakpoint at validate() method of IndexRequest class in &lt;top&gt;\/server\/src\/main\/java\/org\/elasticsearch\/action\/index\/IndexRequest.java <\/p>\n\n\n\n<p>(7) Execute the following comannd at commandline. <\/p>\n\n\n\n<p>curl -X POST &#8220;http:\/\/elastic:password@localhost:9200\/my-index-000001\/_doc?pretty&#8221; -H &#8220;Content-Type: application\/json&#8221; -d &#8220;{\\&#8221;title\\&#8221;: \\&#8221;test document\\&#8221;}&#8221;<\/p>\n\n\n\n<p>(8) If you see that Elasticsearch stops at (6) breakpoint, your Debugging insert command successes.<\/p>\n\n\n\n<p>(9) Create a breakpoint at start() method of AbstractSearchAsyncAction class in &lt;top&gt;\/server\/src\/main\/java\/org\/elasticsearch\/action\/search\/AbstractSearchAsyncAction.java<\/p>\n\n\n\n<p>(10) Execute the following comannd at commandline. <\/p>\n\n\n\n<p>curl -X POST &#8220;http:\/\/elastic:password@localhost:9200\/my-index-000001\/_doc?pretty&#8221; -H &#8220;Content-Type: application\/json&#8221; -d &#8220;{\\&#8221;title\\&#8221;: \\&#8221;test document\\&#8221;}&#8221;<\/p>\n\n\n\n<p>(11) If you see that Elasticsearch stops at (9) breakpoint, your Debugging search command successes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. References<\/h2>\n\n\n\n<p>[1] Contributing to elasticsearch<br><a href=\"https:\/\/github.com\/elastic\/elasticsearch\/blob\/master\/CONTRIBUTING.md\">https:\/\/github.com\/elastic\/elasticsearch\/blob\/master\/CONTRIBUTING.md<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-150","post","type-post","status-publish","format-standard","hentry","category-elasticsearch","entry"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/posts\/150","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/osmanthus.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=150"}],"version-history":[{"count":4,"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions"}],"predecessor-version":[{"id":157,"href":"https:\/\/osmanthus.work\/index.php?rest_route=\/wp\/v2\/posts\/150\/revisions\/157"}],"wp:attachment":[{"href":"https:\/\/osmanthus.work\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=150"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osmanthus.work\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=150"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osmanthus.work\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=150"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}