# Index created with out adding any data

**URL:** https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954
**Category:** Elasticsearch
**Created:** [June 29, 2018, 11:40am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954 "2018-06-29T11:40:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![aneesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aneesh/32/37819_2.png) [@aneesh](https://discuss.elastic.co/u/aneesh)
#### Post date: [June 29, 2018, 11:40am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/1 "2018-06-29T11:40:02Z")

</div>

Hi

Sometimes when adding new data to elastic. index is created but data not added.  
Success is coming as true.  
Where I can check these kind of error.  
I am using [ElasticSearch.Net](http://ElasticSearch.Net) 5.5.0 and NEST 5.5.0 (.Net)

Thanks  
Aneesh L

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [June 29, 2018, 9:54pm UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/2 "2018-06-29T21:54:28Z")

</div>

Can you provide more detail about how you're indexing? Can you show an example of code to demonstrate?

---

<div class="post-metadata">

### Author: ![aneesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aneesh/32/37819_2.png) [@aneesh](https://discuss.elastic.co/u/aneesh)
#### Post date: [July 2, 2018, 5:32am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/3 "2018-07-02T05:32:42Z")

</div>

I am doing bulk insert of 5000 rows at a time

```
int result = jaData.Count / 5000;
    int reminder = jaData.Count % 5000;
    if (reminder != 0)
        result++;
    ElasticsearchResponse < Stream > indexResponse = null;
    List < List < object >> lstLstRowsToCache = new List<List<object>>();
    for (int jIndex = 0; jIndex < result; jIndex++)
    {
        List < object > lstRowsToCache = new List<object>();
        int i = 5000 * jIndex;
        for (int iIndex = i; iIndex < (i + 5000) && iIndex < jaData.Count; iIndex++)
        {
            JObject JOEntityRow = new JObject();
            JOEntityRow = (JObject)jaData[iIndex];
            string strId = string.IsNullOrWhiteSpace(strPKName) ? Guid.NewGuid().ToString() :
                (JOEntityRow[strPKName] == null ? Guid.NewGuid().ToString() : JOEntityRow[strPKName].ToString());
            lstRowsToCache.Add(
                new
                    {
                        index =
                        new
                            {
                                _index = strIndex,
                                _type = strType,
                                _id = strId,
                                version = DateTime.Now.Ticks.ToString(),
                                version_type = "external"
                            }
                    });
            lstRowsToCache.Add(JOEntityRow);
        }
        lstLstRowsToCache.Add(lstRowsToCache);
    }
    foreach(var lstRows in lstLstRowsToCache)
    {
        indexResponse = objClient.Bulk<Stream>(lstRows);
        if (!indexResponse.Success) {
            //Fail
        }
    }
```

---

<div class="post-metadata">

### Author: ![forloop](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/forloop/32/9021_2.png) [@forloop](https://discuss.elastic.co/u/forloop)
#### Post date: [July 2, 2018, 10:59am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/4 "2018-07-02T10:59:23Z")

</div>

> [@aneesh](#):
>
> indexResponse = objClient.Bulk\<Stream\>(lstRows); if (!indexResponse.Success) { //Fail }

It looks like you're using the low level client and returning a `Stream` response, but not checking the individual results in the response body (which would mean reading from the stream). I suspect that documents are failing to be indexed in the bulk request. With the low level client, the `.Success` property is determined from the HTTP response status code:

> <https://github.com/elastic/elasticsearch-net/blob/a5a92b9cbb4df06e8e6f34635a80180d2c1e0792/src/Elasticsearch.Net/Transport/Pipeline/ResponseBuilder.cs#L56-L62>

In the case of the bulk response, a `200` can be returned, even where some of the operations within the request have failed.

Take a look at the [bulk API documentation to see what is returned for each bulk operation](https://www.elastic.co/guide/en/elasticsearch/reference/6.2/docs-bulk.html). Specifically, you'll need to look at the `"errors"` property first, and if that's `true`, look at each operation to handle the failed operations.

---

<div class="post-metadata">

### Author: ![aneesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aneesh/32/37819_2.png) [@aneesh](https://discuss.elastic.co/u/aneesh)
#### Post date: [July 6, 2018, 9:03am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/5 "2018-07-06T09:03:06Z")

</div>

I will try this. Thanks

---

<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: [August 3, 2018, 9:12am UTC](https://discuss.elastic.co/t/index-created-with-out-adding-any-data/137954/6 "2018-08-03T09:12:35Z")

</div>

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