# Java IndexRequest Default value of type

**URL:** https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094
**Category:** Elasticsearch
**Created:** [January 21, 2019, 5:03pm UTC](https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094 "2019-01-21T17:03:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gormanst](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gormanst](https://discuss.elastic.co/u/gormanst)
#### Post date: [January 21, 2019, 5:03pm UTC](https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094/1 "2019-01-21T17:03:34Z")

</div>

If I do not specify "\_doc" as my type in an IndexRequest like so,

```
`new IndexRequest(esIndex, "_doc",record.getIndex())
                    .source(esRecord.getData().toString(), XContentType.JSON)`

```

I get the exception,  
exception [type=illegal\_argument\_exception, reason=Rejecting mapping update to [cartoon-raw-ekenebt-2019-01-21] as the final mapping would have more than 1 type: [\_doc, SEEC0746A8F2B5\_26JUL071p0019145AASEEC079j000999]]]]

I can't figure out why adding "\_doc" fixes this exception?

Running version 6.2.4

---

<div class="post-metadata">

### Author: ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)
#### Post date: [January 21, 2019, 5:50pm UTC](https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094/2 "2019-01-21T17:50:31Z")

</div>

There are a number of constructors for `IndexRequest`, and the two relevant ones here are:

```auto
    public IndexRequest(String index, String type);
    public IndexRequest(String index, String type, String id);

```

When you pass three arguments you are giving the index, the type, and the document ID, but when you pass two you are giving the index and the **type**. The error message indicates that you are passing `SEEC0746A8F2B5_26JUL071p0019145AASEEC079j000999` for the type, but this looks like a document ID, and that is probably not what you want.

---

<div class="post-metadata">

### Author: ![gormanst](https://avatars.discourse-cdn.com/v4/letter/g/87869e/32.png) [@gormanst](https://discuss.elastic.co/u/gormanst)
#### Post date: [January 21, 2019, 7:01pm UTC](https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094/3 "2019-01-21T19:01:12Z")

</div>

I am doing this in preparation for the removal of mapping types in elasticsearch. This is where I used to have my project specific type value. With the removal of types, will I always put "\_doc" in for the type field? I know there is the notion of custom types but in general what should I put in for type once I have removed type from my index mapping?

---

<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 18, 2019, 7:01pm UTC](https://discuss.elastic.co/t/java-indexrequest-default-value-of-type/165094/4 "2019-02-18T19:01:13Z")

</div>

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