Index created with out adding any data

(Arcadix Infotech Pvt.Ltd) #1


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 5.5.0 and NEST 5.5.0 (.Net)

Aneesh L

(Russ Cam) #2

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

(Arcadix Infotech Pvt.Ltd) #3

I am doing bulk insert of 5000 rows at a time

int result = jaData.Count / 5000;
    int reminder = jaData.Count % 5000;
    if (reminder != 0)
    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());
                        index =
                                _index = strIndex,
                                _type = strType,
                                _id = strId,
                                version = DateTime.Now.Ticks.ToString(),
                                version_type = "external"
    foreach(var lstRows in lstLstRowsToCache)
        indexResponse = objClient.Bulk<Stream>(lstRows);
        if (!indexResponse.Success) {

(Russ Cam) #4

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:

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. 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.

(Arcadix Infotech Pvt.Ltd) #5

I will try this. Thanks

(system) #6

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