# Data inconsistency in bulk indexing to ES child index

**URL:** <https://discuss.elastic.co/t/data-inconsistency-in-bulk-indexing-to-es-child-index/77760>\
**Category:** Elasticsearch\
**Created:** [March 8, 2017, 5:26am UTC](https://discuss.elastic.co/t/data-inconsistency-in-bulk-indexing-to-es-child-index/77760 "2017-03-08T05:26:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hari\_india](https://avatars.discourse-cdn.com/v4/letter/h/e495f1/32.png) [@hari\_india](https://discuss.elastic.co/u/hari_india)\
**Post date:** [March 8, 2017, 5:26am UTC](https://discuss.elastic.co/t/data-inconsistency-in-bulk-indexing-to-es-child-index/77760/1 "2017-03-08T05:26:39Z")

</div>

I'm using ElasticSearch 1.7.5. I have a scenario of bulkindexing to child index. It's been noticed that some data getting missed during the bulkindexing and sometimes data from one bulk instance get merged with another, causing inconsistency.  
The sample code I'm using pasting below.

```
public void writeToChildIndex(List<ClassInfo> classInfoList) {
	childInfo obj = null;
	BulkRequestBuilder bulkRequestBuilder = null;
	IndexRequestBuilder requestBuilder = null;
	BulkIndexThread bulkIndexThredObj = null;
	try {
		for (ClassInfo classInfo : classInfoList) {
			bulkRequestBuilder = writeClient.prepareBulk(); 

			for (String entryId : classInfo.post_id_set) {
				obj = new TextThemeChildInfo();

				obj.infoId = classInfo.infoId;
				obj.entry_id = entryId;
				obj.category = classInfo.category;

				requestBuilder = writeClient.prepareIndex("index", "child", classInfo.infoId + entryId);
                                    //writeClient is the connection client variable
				requestBuilder.setSource(JSONConverter.toJsonString(obj));//convert POJO to json string
				requestBuilder.setParent(entryId);

				bulkRequestBuilder.add(requestBuilder);
			}
			
			bulkRequestBuilder.execute().actionGet();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}

```

Could you find any issue with the code or is there any issue with this ES version?

---

<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:** [April 5, 2017, 5:26am UTC](https://discuss.elastic.co/t/data-inconsistency-in-bulk-indexing-to-es-child-index/77760/2 "2017-04-05T05:26:49Z")

</div>

Closed on April 5, 2017, 5:26am UTC

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