# Add multiple data values to Elasticsearch index using java REST API

**URL:** <https://discuss.elastic.co/t/add-multiple-data-values-to-elasticsearch-index-using-java-rest-api/244938>\
**Category:** Elasticsearch\
**Created:** [August 13, 2020, 7:10pm UTC](https://discuss.elastic.co/t/add-multiple-data-values-to-elasticsearch-index-using-java-rest-api/244938 "2020-08-13T19:10:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venkat\_Raj](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/venkat_raj/32/51823_2.png) [@Venkat\_Raj](https://discuss.elastic.co/u/Venkat_Raj)\
**Post date:** [August 13, 2020, 7:10pm UTC](https://discuss.elastic.co/t/add-multiple-data-values-to-elasticsearch-index-using-java-rest-api/244938/1 "2020-08-13T19:10:29Z")

</div>

Hi All,  
I am using JAVA REST API to create index and add data to the index.  
Below is the code I am using:

```auto
Map<String, Object> dataMap = new HashMap<String, Object>();
dataMap.put("appname", app);
dataMap.put("version", version);
.
.
.
IndexRequest indexRequest = new IndexRequest("appindex").source(dataMap);
IndexResponse indexResponse = client.index(indexRequest, RequestOptions.DEFAULT);

```

This piece of code works perfectly to create index and add the the dataMap to the index.

My requirement is that I need to iterate over a list of object and add datas to dataMap then add the dataMap to the index.  
For instance -

```auto
Iterate over a object(){
dataMap.add("key", Value)
dataMap.add("Key", Value)
Add data to index
} move to next iteration.

```

Is this kind of operation possible using JAVA REST API?

---

<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 10, 2020, 7:10pm UTC](https://discuss.elastic.co/t/add-multiple-data-values-to-elasticsearch-index-using-java-rest-api/244938/2 "2020-09-10T19:10:38Z")

</div>

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