# Java High Level Rest Create Index API

**URL:** https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517
**Category:** Elasticsearch
**Created:** [February 10, 2020, 6:16am UTC](https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517 "2020-02-10T06:16:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![andrewmk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewmk/32/46385_2.png) [@andrewmk](https://discuss.elastic.co/u/andrewmk)
#### Post date: [February 10, 2020, 6:16am UTC](https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517/1 "2020-02-10T06:16:52Z")

</div>

I'm getting the error:  
Type mismatch: cannot convert from org.elasticsearch.action.admin.indices.create.CreateIndexResponse to org.elasticsearch.client.indices.CreateIndexResponse

```
CreateIndexRequest request = new CreateIndexRequest("index"); 

request.settings(Settings. builder () 

.put("index.number_of_shards", 3)

.put("index.number_of_replicas", 2)

);

CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT);

```

Can anyone help me with this please?

Thank you!

---

<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: [February 10, 2020, 10:02am UTC](https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517/2 "2020-02-10T10:02:22Z")

</div>

Change the `import` line in your class I think.

From:

```auto
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;

```

to

```auto
import org.elasticsearch.client.indices.CreateIndexResponse;

```

---

<div class="post-metadata">

### Author: ![andrewmk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrewmk/32/46385_2.png) [@andrewmk](https://discuss.elastic.co/u/andrewmk)
#### Post date: [February 22, 2020, 3:42am UTC](https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517/3 "2020-02-22T03:42:49Z")

</div>

> [@dadoonet](#):
>
> ```auto
> import org.elasticsearch.client.indices.CreateIndexResponse;
> 
> ```

It seems Eclipse was adding  
`import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;`  
when it should have been  
`import org.elasticsearch.client.indices.CreateIndexRequest;`

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: [March 21, 2020, 3:42am UTC](https://discuss.elastic.co/t/java-high-level-rest-create-index-api/218517/4 "2020-03-21T03:42:57Z")

</div>

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