Java中的
try {
…………………………………
logger.info("Delete Document " + uri);
docMgr.delete("rocky-mountains");
System.out.println("Deleted");
} catch (Exception e) {
logger.error("Exception : " + e.toString() );
}文档
rocky-mountains不存在,但是API愉快地声明了Deleted
Jul 05, 2020 9:35:04 PM com.fc.allegro.DeleteDocument deleteDocument
INFO: Delete Document rocky-mountains
Jul 05, 2020 9:35:04 PM com.marklogic.client.impl.DocumentManagerImpl delete
INFO: Deleting rocky-mountains
Deleted在查询控制台中,
eval检测并抛出错误:
[1.0-ml] XDMP-DOCNOTFOUND: xdmp:document-delete("rocky-mountains") -- Document not found QueryBatcher batcher = dmManager.newQueryBatcher(new StructuredQueryBuilder().document("rocky-mountains"));
batcher.onUrisReady(new DeleteListener())
.onQueryFailure( exception -> exception.printStackTrace() );结果:
Jul 05, 2020 9:52:07 PM com.marklogic.client.datamovement.impl.QueryBatcherImpl withForestConfig
INFO: (withForestConfig) Using forests on [localhost] hosts for "allegro"
Batch Deleted
INFO: Job complete, jobBatchNumber=1, jobResultsSoFar=0我尝试了检查和未检查的异常,但没有结果。
哪个MarkLogic类和方法会强制抛出异常并降低风险?

失败:

成功:

发布于 2020-07-06 07:01:51
运行xdmp:document-delete与使用Java删除文档有一个重要的区别。Java是MarkLogic REST-API的包装器,它遵循RESTful API的规则。RESTful API的一个重要规则是,预期调用是幂等的。简而言之,这意味着您应该能够运行两次电话,并得到相同的答复两次。这就是为什么调用insert、update和delete在文档不存在或不存在时不抛出错误的原因。
另见例如:https://restfulapi.net/http-methods/#delete
如果您希望应用程序更加严格,我建议您使用Data或自定义REST扩展。
哈哈!
https://stackoverflow.com/questions/62748891
复制相似问题