1
votes

I am trying to transition from ElasticSearch 2 to either 5 or 6. I think that I want to jump straight to 6.1.1 and use the RestHighLevelClient, since it is closer to the existing transport client that I am using than the low level rest client.

However, I am running across a problem As part of my integration tests, I'm creating an index and inserting particular data, so I know that my queries are correct. I can't seem to do that in the High Level client. In particular, I want to be able to call:

  RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost(host, port)))
  client.indices()
        .preparePutMapping(databaseName)
        .setType(tableName).etc....

However, client.indices() returns an org.elasticsearch.client.IndicesClient (from org.elasticsearch.client:elasticsearch-rest-high-level-client:6.1.1) which does not have a preparePutMapping(). I need a org.elasticsearch.client.IndicesAdminClient (from org.elasticsearch:elasticsearch:6.1.1). I can't figure out how to get that, from either RestHighLevelClient or RestClient.

Am I out of luck? Is this just transition pains that it has not been implemented yet? Or something more permanent?

1

1 Answers

0
votes

Looking at the documentation:

client.admin().indices()
      .preparePutMapping(databaseName)   
      .setType(tableName)
      ...

Looks like all you need is an additional .admin().