# Validation failed because of missing type with hl rest client bulk API

**URL:** https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060
**Category:** Elasticsearch
**Created:** [August 21, 2019, 8:05am UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060 "2019-08-21T08:05:44Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![zhaozeyang](https://avatars.discourse-cdn.com/v4/letter/z/ad7895/32.png) [@zhaozeyang](https://discuss.elastic.co/u/zhaozeyang)
#### Post date: [August 21, 2019, 8:05am UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060/1 "2019-08-21T08:05:45Z")

</div>

hello :  
this is my code:

```
    BulkRequest request = new BulkRequest();
    for (DataInfo dataInfo : dataInfos) {
        String index = getCurrentIndex(dataInfo.getIndexPrefix());
        String id = dataInfo.getId();
        IndexRequest indexRequest = new IndexRequest(index).id(id).opType(DocWriteRequest.OpType.CREATE);
        String source = GsonEntityMapper.mapToString(dataInfo.getData());
        indexRequest.source(source, XContentType.JSON);
        request.add(indexRequest);
    }
    client.bulk(request, RequestOptions.DEFAULT);

```

The return value is ‘ type is missing ’ when I execute it；

i want know what‘s the problem whit the code

---

<div class="post-metadata">

### Author: ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)
#### Post date: [August 21, 2019, 8:29am UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060/2 "2019-08-21T08:29:44Z")

</div>

Hi @zhaozeyang,

which version of ES and the high level rest client are you using? If before 7, you need to specify a type for your index request too. To avoid changing this later on, I recommend using the type '\_doc'. See: [https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0](https://www.elastic.co/blog/moving-from-types-to-typeless-apis-in-elasticsearch-7-0) for more info on types removal.

---

<div class="post-metadata">

### Author: ![zhaozeyang](https://avatars.discourse-cdn.com/v4/letter/z/ad7895/32.png) [@zhaozeyang](https://discuss.elastic.co/u/zhaozeyang)
#### Post date: [August 21, 2019, 9:21am UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060/3 "2019-08-21T09:21:35Z")

</div>

The version of client is 7.3.0 ; The version of es is 6.8.0  
Is the es version is too low？

---

<div class="post-metadata">

### Author: ![HenningAndersen](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/henningandersen/32/48188_2.png) [@HenningAndersen](https://discuss.elastic.co/u/HenningAndersen)
#### Post date: [August 22, 2019, 12:47pm UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060/4 "2019-08-22T12:47:18Z")

</div>

Hi @zhaozeyang,

It is not recommended to use such a combination, see: [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-high-compatibility.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.3/java-rest-high-compatibility.html)

But I think the problem would be solved by specifying the type in the request, also with the current combination of client and ES.

---

<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: [September 19, 2019, 12:47pm UTC](https://discuss.elastic.co/t/validation-failed-because-of-missing-type-with-hl-rest-client-bulk-api/196060/5 "2019-09-19T12:47:20Z")

</div>

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