# Elastic Search Java API documentation lacking

**URL:** <https://discuss.elastic.co/t/elastic-search-java-api-documentation-lacking/762>\
**Category:** Elasticsearch\
**Created:** [May 15, 2015, 5:09pm UTC](https://discuss.elastic.co/t/elastic-search-java-api-documentation-lacking/762 "2015-05-15T17:09:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_MacRitchie](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@Scott\_MacRitchie](https://discuss.elastic.co/u/Scott_MacRitchie)\
**Post date:** [May 15, 2015, 5:09pm UTC](https://discuss.elastic.co/t/elastic-search-java-api-documentation-lacking/762/1 "2015-05-15T17:09:12Z")

</div>

Hi all, I'm running elasicsearch 1.5.2 embedded in my java app. I spent most of a day trying to add a custom dynamic mapping to my index via the CreateIndexRequestBuilder Java API to disable date detection.  
I used the documentation here as my guide:  
[https://www.elastic.co/guide/en/elasticsearch/guide/master/custom-dynamic-mapping.html](https://www.elastic.co/guide/en/elasticsearch/guide/master/custom-dynamic-mapping.html)  
I kept getting a "Root type mapping not empty after parsing" error any time I tried to add the mapping. Adding the mapping via the REST API always worked fine.  
After a lot of forum searching (which didn't help) and fiddling around I discovered the "mappings" node in the example needed to be removed when using the Java API.  
This is the JSON the guide says to use with the REST API:

```
{
"mappings": {
    "my_type": {
        "date_detection": false
    }
}

```

}

This is the JSON I had to use to get the Java API to work:

```
 {
    "my_type": {
        "date_detection": false
    }
}

```

I couldn't find documentation about that anywhere. If it exists, could someone point me in the right direction so I know for next time? I think it would be very helpful to have more examples of how to use the Java API along side the REST API, especially for calls that require you to supply a JSON document as input.

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [May 15, 2015, 5:43pm UTC](https://discuss.elastic.co/t/elastic-search-java-api-documentation-lacking/762/2 "2015-05-15T17:43:42Z")

</div>

In general, the unit and integration tests are the best way to find how  
the Java API is used. The Rest Action classes are another way, but more  
generic.

Cheers,

Ivan

---

<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:** [July 6, 2017, 12:13am UTC](https://discuss.elastic.co/t/elastic-search-java-api-documentation-lacking/762/3 "2017-07-06T00:13:50Z")

</div>


