1
特定Elasticsearch例外,我用Java指数与BulkRequest
到Elasticsearch 1.4.2一些文件。捕捉来自BulkRequest
其中一些文档只需要写入的时候,他们是不是已经在索引中,所以我设置了CREATE-OPTYPE这样的:
indexRequestBuilder.opType(IndexRequest.OpType.CREATE)
现在它已经在索引的文档中失败BulkResponse。
错误消息bulkItemResponse.getFailureMessage()
:
DocumentAlreadyExistsException [...]
我想忽略这个类的异常,但试写文档的所有其他类型的例外。
因此,如何能赶上我只DocumentAlreadyExistsException
?
我可以得到Failure
bulkItemResponse.getFailure()
,但我找不到有关错误消息旁边的异常类型的任何信息。
我可以看看错误消息的例外名,但是这可能是相当脆弱的新Elasticsearch版本:
if(bulkItemResponse.getFailureMessage().startsWith("DocumentAlreadyExistsException[")
有没有更好的办法?
好吧,我明白了。我希望,在'Failure'类将有一个'exceptionClassName'领域来区分不同的异常类型。我将为我的功能请求打开一个问题。 – Sonson123