Cannot instantiate the type TransportClient

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.

Here is the documentation: 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

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] link and got to know that prepare search only works with transport client.

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

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?

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

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

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

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

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