# Java client's scripts api

**URL:** <https://discuss.elastic.co/t/java-clients-scripts-api/95287>\
**Category:** Elasticsearch\
**Created:** [August 1, 2017, 7:03am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287 "2017-08-01T07:03:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [August 1, 2017, 7:03am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/1 "2017-08-01T07:03:07Z")

</div>

Hi, Thank you for your work!

I am trying to use Indexed Scripts API from java.

This is the tutorial that I tested.  
my client does not have those methods and Response classes.

I am using elastic cloud(v5.5.1).

What is the correct way to use 'Indexed Scripts API'.

**code**

```
		PutIndexedScriptResponse = client.preparePutIndexedScript()
                     .setScriptLang("painless")
                     .setId("script1")
                     .setSource("script", "_score * doc['my_numeric_field'].value")
                     .execute()
                     .actionGet();

        GetIndexedScriptResponse = client.prepareGetIndexedScript()
                        .setScriptLang("painless")
                        .setId("script1")
                        .execute()
                        .actionGet();

        DeleteIndexedScriptResponse = client.prepareDeleteIndexedScript()
                        .setScriptLang("painless")
                        .setId("script1")
                        .execute()
                        .actionGet();

```

**POM**

```
    <dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>transport</artifactId>
		<version>5.5.1</version>
	</dependency>
	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>rest</artifactId>
		<version>5.5.1</version>
	</dependency>

	<dependency>
		<groupId>org.elasticsearch.client</groupId>
		<artifactId>x-pack-transport</artifactId>
		<version>5.5.0</version>
	</dependency>

```

**client**

```
   TransportClient javaClient = new PreBuiltXPackTransportClient(settings)
			        .addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(fullhost), 9343));

```

client works fine for other functions.

**error**

```
    1. PutIndexedScriptResponse cannot be resolved to a variable
    2. The method preparePutIndexedScript() is undefined for the type TransportClient

```

Thanks.  
HJ.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 2, 2017, 7:48am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/2 "2017-08-02T07:48:56Z")

</div>

Better not to use images for code parts. Could you update your post please?  
Don't forget to use code formatting with `</>` icon.

Thanks.

Have a look at `client.admin().cluster().putStoredScript()`. That's probably what you are looking at.

---

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [August 3, 2017, 1:59am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/3 "2017-08-03T01:59:54Z")

</div>

I changed images!

and where can i find docs for client.admin().cluster().putStoredScript()?

I could not find any information for client.admin().cluster().putStoredScript() in here.  
[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin.html)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [August 3, 2017, 5:34am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/4 "2017-08-03T05:34:30Z")

</div>

There is no documentation on this.

Just the javadoc and the source code.  
You can look in elasticsearch repository and search for tests using that method. That can really help

---

<div class="post-metadata">

**Author:** ![Hyojoung\_Shin](https://avatars.discourse-cdn.com/v4/letter/h/6a8cbe/32.png) [@Hyojoung\_Shin](https://discuss.elastic.co/u/Hyojoung_Shin)\
**Post date:** [August 4, 2017, 4:54am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/5 "2017-08-04T04:54:27Z")

</div>

thanks!

---

<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:** [September 1, 2017, 4:54am UTC](https://discuss.elastic.co/t/java-clients-scripts-api/95287/6 "2017-09-01T04:54:41Z")

</div>

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