i am using elastic search bulk java api to insertion of record from legacy
db.
i am selecting 100 records per poll and inserting to elasticsearch.
it is working very well and without any error.
but was wondering that what if bulk insertion to elasticsearch fails !
i have seen the api and there is a method for checking that error is there
or not like
bulkResponse.hasFailures()
so do we have to insert entire bulk request again if there is a failure or
we can identify that out of entire request these are
the records which were failed.
You can find out what item has failed in the bulk response.
You can iterate over the bulk response items and check if they failed.
Like this:
if (bulkResponse.hasFailures) {
for (BulkItemResponse item : bulkResponse.items()) {
if (item.failed()) {
// Do something... Use item#failureMessage() to find the cause
of the failure.
}
}
}
i am using Elasticsearch bulk java api to insertion of record from legacy
db.
i am selecting 100 records per poll and inserting to elasticsearch.
it is working very well and without any error.
but was wondering that what if bulk insertion to elasticsearch fails !
i have seen the api and there is a method for checking that error is there
or not like
bulkResponse.hasFailures()
so do we have to insert entire bulk request again if there is a failure or
we can identify that out of entire request these are
the records which were failed.
Thanks Martin !
Yes that is what i wanted....
Cheers !
Mohsin
On Monday, 3 December 2012 11:53:50 UTC, Martijn v Groningen wrote:
Hi Mohsin,
You can find out what item has failed in the bulk response.
You can iterate over the bulk response items and check if they failed.
Like this:
if (bulkResponse.hasFailures) {
for (BulkItemResponse item : bulkResponse.items()) {
if (item.failed()) {
// Do something... Use item#failureMessage() to find the cause
of the failure.
}
}
}
Martijn
On 3 December 2012 21:43, mohsin husen <smh...@gmail.com <javascript:>>
wrote:
hello all,
i am using Elasticsearch bulk java api to insertion of record from
legacy
db.
i am selecting 100 records per poll and inserting to elasticsearch.
it is working very well and without any error.
but was wondering that what if bulk insertion to elasticsearch fails !
i have seen the api and there is a method for checking that error is
there
or not like
bulkResponse.hasFailures()
so do we have to insert entire bulk request again if there is a failure
or
we can identify that out of entire request these are
the records which were failed.
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.