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 5.5.0 and NEST 5.5.0 (.Net)
Thanks
Aneesh L
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 5.5.0 and NEST 5.5.0 (.Net)
Thanks
Aneesh L
Can you provide more detail about how you're indexing? Can you show an example of code to demonstrate?
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
}
}
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.
I will try this. Thanks
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.