我在Cloudant DB (CouchDB)中使用Ektorp executeBulk & ExecuteAllOrNothing函数对文档列表进行批量更新时遇到了一个问题。
对于couchDbConnector.executeAllOrNothing(List<?> list),我得到的错误如下:
org.ektorp.DbAccessException: 417:Expectation Failed
URI: /let-ut-app/_bulk_docs
Response Body:
null
at org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandler.java:44)
at org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:98)
at org.ektorp.http.RestTemplate.post(RestTemplate.java:61)
at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:536)
at org.ektorp.impl.StdCouchDbConnector.executeAllOrNothing(StdCouchDbConnector.java:494)如果我将相同的逻辑更改为使用executeBulk作为couchDbConnector.executeBulk(List<?> list),则错误消息如下:
org.ektorp.DbAccessException: 500:Internal Server Error
URI: /let-ut-app/_bulk_docs
Response Body:
{
"error" : "case_clause",
"reason" : "{12,11}",
"stack" : [ "fabric_doc_update:handle_message/3", "rexi_utils:process_mailbox/6", "rexi_utils:recv/6", "fabric_doc_update:go/3", "fabric:update_docs/3", "chttpd_db:db_req/2", "chttpd:handle_request/1", "mochiweb_http:headers/5" ]
}
at org.ektorp.http.StdResponseHandler.createDbAccessException(StdResponseHandler.java:44)
at org.ektorp.http.StdResponseHandler.error(StdResponseHandler.java:62)
at org.ektorp.http.RestTemplate.handleResponse(RestTemplate.java:98)
at org.ektorp.http.RestTemplate.post(RestTemplate.java:61)
at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:536)
at org.ektorp.impl.StdCouchDbConnector.executeBulk(StdCouchDbConnector.java:498)如果你们中有人遇到这个问题,请让我知道你们是如何解决这个问题的。
感谢你的帮助。
非常感谢!
发布于 2014-10-05 14:41:36
我在cloudant服务器上看到了类似的情况。我直接使用rest客户端进行调用:
不幸的是,这段代码不能处理批量保存的两个选项(uuid和all或none)。您可以查看couchrest代码并自己实现(但我还没有这样做)。
# this couchrest will throw an exception on some couchdb servers
# db.bulk_save(design_docs, false, true) # no uuids, all or nothing
bulk_docs = {'docs' => design_docs}
responses = CouchRest.post("#{db.root}/_bulk_docs", bulk_docs)https://stackoverflow.com/questions/12914769
复制相似问题