发送put或post请求时,Elasticsearch是否返回错误?

2q5ifsrm  于 2022-11-02  发布在  ElasticSearch
关注(0)|答案(1)|浏览(280)

我的elasticsearch对GET请求(如curl -X GET "localhost:9200")完全有效。
然而,每当我试图通过post或put添加一些东西时,它都会给我错误。
即使是这个简单的示例文档(我从教程中获得的)也不适合我:

curl -XPUT 'http://localhost:9200/blog/article/1' -d '{"title": "New version of Elasticsearch released!", "content": "Version 2.2 released today!", "priority": 10, "tags": ["announce", "elasticsearch", "release"] }'

这是我得到的错误:

{"error":"no handler found for uri [/blog/article/1] and method [PUT]"}

尽管我确信我的语法是正确的,但我总是得到这种错误

ercv8c1e

ercv8c1e1#

您在URL中使用article时使用的是一种类型,该类型已过时很久,不再受支持
请查看深入研究此问题的文档-https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html
试试这样东西;

curl -XPUT 'http://localhost:9200/blog/_doc/1' -d '{"title": "New version of Elasticsearch released!", "content": "Version 2.2 released today!", "priority": 10, "tags": ["announce", "elasticsearch", "release"], "type": "article" }'

相关问题