【异常】ES删除内容时,提示HTTP状态码405 Incorrect HTTP method for uri [//XXX] and method [DELETE], allowed: [POST]

本文档主要介绍了在使用Elasticsearch (ES) 7.x版本时遇到的HTTP 405错误,该错误发生在尝试删除内容时。文章详细解释了错误原因并提供了正确的删除语法。同时,回顾了ES的基本CRUD操作,包括添加、删除、修改、查询、排序、分页、高亮显示和查看字段类型等。

一、报错内容

ES删除文档时

DELETE luckylog/gWlvBocBji44bzvy18YJ

报错如下

{
   
   
    "error":"Incorrect HTTP method for uri [/XXX] and method [DELETE], allowed: [POST]",
    "status":405
}

ElasticsearchStatusException[Elasticsearch exception [type=exception, reason=Incorrect HTTP method for uri [/_update_by_query?slices=1&requests_per_second=-1&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&refresh=true&wait_for_completion=true&timeout=1m] and method [POST], allowed: [HEAD, DELETE, GET, PUT]]] at org.elasticsearch.rest.BytesRestResponse.errorFromXContent(BytesRestResponse.java:187) at org.elasticsearch.client.RestHighLevelClient.parseEntity(RestHighLevelClient.java:1911) at org.elasticsearch.client.RestHighLevelClient.parseResponseException(RestHighLevelClient.java:1888) at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1645) at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:1602) at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:1572) at org.elasticsearch.client.RestHighLevelClient.updateByQuery(RestHighLevelClient.java:603) at com.huawei.rcm.es.EsOperator.updateEs(EsOperator.java:233) at com.huawei.rcm.offline.UpdateEsByKey$.$anonfun$updateEsByKey$1(UpdateEsByKey.scala:97) at com.huawei.rcm.offline.UpdateEsByKey$.$anonfun$updateEsByKey$1$adapted(UpdateEsByKey.scala:89) at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:36) at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:33) at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:198) at com.huawei.rcm.offline.UpdateEsByKey$.updateEsByKey(UpdateEsByKey.scala:89) at com.huawei.rcm.offline.UpdateEsByKey.execute(UpdateEsByKey.scala:45) at com.huawei.rcm.task.RcmTaskBatch.runByStep(RcmTaskBatch.scala:43) at com.huawei.rcm.RcmJobBatch$TaskRunner.runTasks(RcmJobBatch.scala:120) at com.huawei.rcm.RcmJobBatch$TaskRunner.run(RcmJobBatch.scala:167) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://10.34.17.135:9200], URI [/_update_by_query?slices=1&requests_per_second=-1&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&refresh=true&wait_for_completion=true&timeout=1m], status line [HTTP/1.1 405 Method Not Allowed] {"error":"Incorrect HTTP method for uri [/_update_by_query?slices=1&requests_per_second=-1&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&ignore_throttled=true&refresh=true&wait_for_completion=true&timeout=1m] and method [POST], allowed: [HEAD, DELETE, GET, PUT]","status":405} at org.elasticsearch.client.RestClient.convertResponse(RestClient.java:326) at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296) at org.elasticsearch.client.RestClient.performRequest(RestClient.java:270) at org.elasticsearch.client.RestHighLevelClient.internalPerformRequest(RestHighLevelClient.java:1632) ... 19 more
最新发布
10-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

本本本添哥

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值