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