# Java RestHighLevelClient put mapping manually

**URL:** <https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091>\
**Category:** Elasticsearch\
**Created:** [January 18, 2018, 3:29pm UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091 "2018-01-18T15:29:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Onoxider](https://avatars.discourse-cdn.com/v4/letter/o/c6cbf5/32.png) [@Onoxider](https://discuss.elastic.co/u/Onoxider)\
**Post date:** [January 18, 2018, 3:29pm UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/1 "2018-01-18T15:29:37Z")

</div>

Hello,

is there any way to put mapping with RestHighLevelClient?

I know that it's possible with TransportClient via this Doc page:  
[https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin-indices.html](https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-admin-indices.html)

But as for RestHighLevelClient I haven't found any information.

Best regards

Добрый день!

Подскажите, пожалуйста, есть ли возможность задать маппинг через RestHighLevelClient?  
ну или хотя бы через low level client.

с уважением,

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 18, 2018, 3:33pm UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/2 "2018-01-18T15:33:04Z")

</div>

In one of the next versions 6.x, it looks like it will be possible to use the `CreateIndex` API call which will allow to set a mapping at index creation time:

[https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.x/java-rest-high-create-index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/6.x/java-rest-high-create-index.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:** [January 18, 2018, 3:52pm UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/3 "2018-01-18T15:52:03Z")

</div>

Yeah. And here is how I'm doing it in the mean time:

> <https://github.com/dadoonet/fscrawler/blob/master/elasticsearch-client/src/main/java/fr/pilato/elasticsearch/crawler/fs/client/ElasticsearchClient.java#L76-L106>

---

<div class="post-metadata">

**Author:** ![Onoxider](https://avatars.discourse-cdn.com/v4/letter/o/c6cbf5/32.png) [@Onoxider](https://discuss.elastic.co/u/Onoxider)\
**Post date:** [January 19, 2018, 9:02am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/4 "2018-01-19T09:02:23Z")

</div>

I'm sorry, I forgot to mention that the version I'm using is 6.1, so it's better to get to 6.x since it has more features?

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 19, 2018, 9:17am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/5 "2018-01-19T09:17:43Z")

</div>

6.x is not released yet 🙂 that was just a link to documentation of the next future release.

---

<div class="post-metadata">

**Author:** ![Onoxider](https://avatars.discourse-cdn.com/v4/letter/o/c6cbf5/32.png) [@Onoxider](https://discuss.elastic.co/u/Onoxider)\
**Post date:** [January 19, 2018, 10:39am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/6 "2018-01-19T10:39:48Z")

</div>

Yes, 6.1 is the current and it doesn't have CreateIndex API ☹

By the way, for some reason gradle dependency is not working i.e. after ptting the following dependency no packages are being added to the project:

```
compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:6.2.0'
```

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 19, 2018, 10:42am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/7 "2018-01-19T10:42:49Z")

</div>

Normal since 6.2 is not released yet

You can inspire yourself from the code @dadoonet provided earlier, that should do the trick

---

<div class="post-metadata">

**Author:** ![Onoxider](https://avatars.discourse-cdn.com/v4/letter/o/c6cbf5/32.png) [@Onoxider](https://discuss.elastic.co/u/Onoxider)\
**Post date:** [January 19, 2018, 10:44am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/8 "2018-01-19T10:44:26Z")

</div>

Thank you, I'll look through it.

You are doing a workaround by getting lowlevelclient and performing basic http requests to put mapping, am I correct?

---

<div class="post-metadata">

**Author:** ![Onoxider](https://avatars.discourse-cdn.com/v4/letter/o/c6cbf5/32.png) [@Onoxider](https://discuss.elastic.co/u/Onoxider)\
**Post date:** [January 19, 2018, 10:46am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/9 "2018-01-19T10:46:16Z")

</div>

Yeah, apparently this is only way to do.

So, to sum up, there's no way in current stable version(6.1) to put mapping via High Level Client only, right?

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 19, 2018, 10:49am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/10 "2018-01-19T10:49:45Z")

</div>

Correct. As far as I know.

---

<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:** [February 16, 2018, 10:50am UTC](https://discuss.elastic.co/t/java-resthighlevelclient-put-mapping-manually/116091/11 "2018-02-16T10:50:03Z")

</div>

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