# Hello World ES Plugin

**URL:** <https://discuss.elastic.co/t/hello-world-es-plugin/141617>\
**Category:** Elasticsearch\
**Created:** [July 25, 2018, 3:50pm UTC](https://discuss.elastic.co/t/hello-world-es-plugin/141617 "2018-07-25T15:50:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marco\_Costantini](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Marco\_Costantini](https://discuss.elastic.co/u/Marco_Costantini)\
**Post date:** [July 25, 2018, 3:50pm UTC](https://discuss.elastic.co/t/hello-world-es-plugin/141617/1 "2018-07-25T15:50:35Z")

</div>

My goal is to test the invocation of some in-house software from within an ES plugin. My approach was to make a simple, Hello World style plugin that would print to the ES log/console. If I can see my log output, then I know when my code path is being triggered. This way, I can hook in my desired invocation, and know when it is being invoked.

Using the examples from the source code, I was able to make a bare-bones NativeScriptPlugin (I prefer this type of plugin for other reasons). It compiles, and the plugin zip installs without error, but I cannot seem to invoke it. That is my problem. I think the root problem is my lack of understanding of the plugin system and ES, but I am not really seeing any docs with any detail. I only see the docs on "Help for plugin authors", but that is minimal.

Here is the curl I use to try and invoke my plugin.

```
curl -XPOST 'localhost:9200/_search' -d '
{
  "query": {
    "script": {
      "script": {
                "name": "invoke_schema",
                "lang" : "native"
      }
    }
  }
}
'

```

The name of the script is correct. I am using ES 5.5.2.

I've tried debugging into the plugin, which works, but doesn't enter the `run()` method of the plugin. I have the `run()` method doing a `System.out.println`, hoping to see something in the ES console output. Sadly, none of this worked as I expected.

Any ideas? Please and thank you.

---

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [July 25, 2018, 4:04pm UTC](https://discuss.elastic.co/t/hello-world-es-plugin/141617/2 "2018-07-25T16:04:33Z")

</div>

Do you have any documents in your index? A search script is run for each document matching the query (in this case, all documents in the index). Additionally, printing to stdout will be a black hole, depending on how you started elasticsearch, and it definitely will not go the the elasticsearch log. You need to construct a Logger for your class and log at a level that is visible (by default, INFO and above).

---

<div class="post-metadata">

**Author:** ![Marco\_Costantini](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Marco\_Costantini](https://discuss.elastic.co/u/Marco_Costantini)\
**Post date:** [July 26, 2018, 9:48am UTC](https://discuss.elastic.co/t/hello-world-es-plugin/141617/3 "2018-07-26T09:48:08Z")

</div>

Thanks for your help. I achieved my goal but with the following findings.

The script I ended up using to invoke the plugin was:

```
curl -XPOST 'localhost:9200/twitter/type/1/_update' -d '
{
  "query": {
    "scripted_upsert": true,
    "upsert" : {},
      "script": {
        "inline": "invoke_schema",
        "lang" : "native"
      }
  }
}
'

```

- I did not need any documents for this type of invocation.
- Because I launched a local ES from bash, `System.out.println` worked fine for my needs.

Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 23, 2018, 9:56am UTC](https://discuss.elastic.co/t/hello-world-es-plugin/141617/4 "2018-08-23T09:56:32Z")

</div>

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