# Cannot instantiate the type TransportClient

**URL:** https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725
**Category:** Elasticsearch
**Created:** [July 26, 2018, 9:16am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725 "2018-07-26T09:16:54Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![BleedCode](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BleedCode](https://discuss.elastic.co/u/BleedCode)
#### Post date: [July 26, 2018, 9:16am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/1 "2018-07-26T09:16:54Z")

</div>

For fetching data from multiple indices, i am trying to use SearchResponse client. But while creating transportClient i get instantiate error. What wrong i am doing?

Following is my code snippet:

> public void setup() throws Exception {  
> Client client = new TransportClient()  
> .addTransportAddress(new InetSocketTransportAddress(  
> "localhost", 9300));}

and SearchResponse code is:

> SearchResponse response = client.prepareSearch(index).setTypes(type).setQuery(QueryBuilders.wrapperQuery(query))  
> .execute().actionGet();

One more doubt can we use jest client for multiple indices search?  
I am using elasticsearch version 6.2.

---

<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: [July 26, 2018, 9:44am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/2 "2018-07-26T09:44:02Z")

</div>

Here is the documentation: [https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/transport-client.html)

But you should move to the Rest client instead: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/index.html)

---

<div class="post-metadata">

### Author: ![BleedCode](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BleedCode](https://discuss.elastic.co/u/BleedCode)
#### Post date: [July 26, 2018, 9:54am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/3 "2018-07-26T09:54:37Z")

</div>

I am trying to perform multiple indices search and i don't find anything like prespareSearch() in rest high level client. But you can suggest me what i can use in restHighLevelClient. I followed [[https://www.elastic.co/guide/en/elasticsearch/client/java-api/6.2/java-search.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/6.2/java-search.html)] link and got to know that prepare search only works with transport client.

---

<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: [July 26, 2018, 10:23am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/4 "2018-07-26T10:23:54Z")

</div>

Did you read the documentation? [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-search.html)

---

<div class="post-metadata">

### Author: ![BleedCode](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BleedCode](https://discuss.elastic.co/u/BleedCode)
#### Post date: [July 26, 2018, 10:33am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/5 "2018-07-26T10:33:35Z")

</div>

I read about multi-search and i am tried using same in ES 6.2, but when i am sending request like:

> MultiSearchResponse response = client.msearch(request, RequestOptions.DEFAULT);

I get error on RequestOptions cannot be resolved to a variable, where is RequestOption class?

---

<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: [July 26, 2018, 10:59am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/6 "2018-07-26T10:59:01Z")

</div>

I think that multisearch is only available from 6.3.  
It's not part of the documentation of 6.2: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.2/index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.2/index.html)

But you can use the Rest client 6.3 with elasticsearch 6.2.  
Or better upgrade your server to elasticsearch 6.3.

---

<div class="post-metadata">

### Author: ![BleedCode](https://avatars.discourse-cdn.com/v4/letter/b/a87d85/32.png) [@BleedCode](https://discuss.elastic.co/u/BleedCode)
#### Post date: [July 26, 2018, 11:42am UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/7 "2018-07-26T11:42:49Z")

</div>

I am very much eager to know, how to use rest client 6.3 with ES 6.2 is there any documentation on that?

---

<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: [July 26, 2018, 12:03pm UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/8 "2018-07-26T12:03:03Z")

</div>

You are asking for documentation but I feel like you are reading it.

So here we go again: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-compatibility.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-compatibility.html)

---

<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, 12:03pm UTC](https://discuss.elastic.co/t/cannot-instantiate-the-type-transportclient/141725/9 "2018-08-23T12:03:08Z")

</div>

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