# Unable to create mapping and settings using Java API

**URL:** <https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307>\
**Category:** Elasticsearch\
**Created:** [May 1, 2014, 9:10pm UTC](https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307 "2014-05-01T21:10:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_Soni](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Amit\_Soni](https://discuss.elastic.co/u/Amit_Soni)\
**Post date:** [May 1, 2014, 9:10pm UTC](https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307/1 "2014-05-01T21:10:37Z")

</div>

hello everyone - I have settings and mapping defined in a single JSON  
document and I have been trying to find a way to create index using that  
JSON document. I tried different code snippets but have not found one which  
allows me to create settings as well as mapping using one JSON document.

Any help on this will be great!

-Amit.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![mikemccand](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@mikemccand](https://discuss.elastic.co/u/mikemccand)\
**Post date:** [May 2, 2014, 10:46am UTC](https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307/2 "2014-05-02T10:46:36Z")

</div>

Hmm, I'm able to create an index and its mappings/settings with a single  
JSON request to [http://localhost:9200/](http://localhost:9200/).

What settings are you trying to set?

Mike

[http://blog.mikemccandless.com](http://blog.mikemccandless.com)

On Thu, May 1, 2014 at 5:10 PM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:

> hello everyone - I have settings and mapping defined in a single JSON  
> document and I have been trying to find a way to create index using that  
> JSON document. I tried different code snippets but have not found one which  
> allows me to create settings as well as mapping using one JSON document.
> 
> Any help on this will be great!
> 
> -Amit.
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y\_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Amit\_Soni](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@Amit\_Soni](https://discuss.elastic.co/u/Amit_Soni)\
**Post date:** [May 7, 2014, 4:34am UTC](https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307/3 "2014-05-07T04:34:14Z")

</div>

Actually I am using Java API which uses a node client (do not have http  
port open). Finally I got it working but it look a bit amount of research.  
Following is the code snippet:

```
    CreateIndexRequest indexCreateRequest = new

```

CreateIndexRequest(indexName);  
indexCreateRequest.source(mappingSource); //entire JSON scrpit  
//Execute index creation command  
CreateIndexResponse indexCreateResponse =  
client.admin().indices().create(indexCreateRequest).actionGet();

-Amit.

On Fri, May 2, 2014 at 3:46 AM, Michael McCandless \<  
[michael.mccandless@elasticsearch.com](mailto:michael.mccandless@elasticsearch.com)\> wrote:

> Hmm, I'm able to create an index and its mappings/settings with a single  
> JSON request to [http://localhost:9200/](http://localhost:9200/).
> 
> What settings are you trying to set?
> 
> Mike
> 
> [http://blog.mikemccandless.com](http://blog.mikemccandless.com)
> 
> On Thu, May 1, 2014 at 5:10 PM, Amit Soni [amitsoni29@gmail.com](mailto:amitsoni29@gmail.com) wrote:
> 
> > hello everyone - I have settings and mapping defined in a single JSON  
> > document and I have been trying to find a way to create index using that  
> > JSON document. I tried different code snippets but have not found one which  
> > allows me to create settings as well as mapping using one JSON document.
> > 
> > Any help on this will be great!
> > 
> > -Amit.
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BEUsstyy7qdNq%2BRmHzA-Rp9mYNYnOoQ8HESiGAvXwXVg%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y\_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com)[https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y\_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/CAD7smRc-y_futLvWVuycgpxwSshJHawNWu8zrDkmZrfZ5sAnZw%40mail.gmail.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BA9evo\_zsdF9BwcxdwXfEwfR1-6YYLRwEAkWurGVorwQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAAOGaQ%2BA9evo_zsdF9BwcxdwXfEwfR1-6YYLRwEAkWurGVorwQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:31am UTC](https://discuss.elastic.co/t/unable-to-create-mapping-and-settings-using-java-api/17307/4 "2017-07-06T01:31:11Z")

</div>


