elasticsearch - 如果映射类型已被删除,为什么我必须将新文档放入嵌套 URI?
问题描述
我在 Elasticsearch 7.14.0 上,其中映射类型已被删除。
如果我运行以下命令:
curl -X PUT "localhost:9200/products/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Toast"
}
'
我明白了
{
"error" : "Incorrect HTTP method for uri [/products/1?pretty] and method [PUT], allowed: [POST]",
"status" : 405
}
似乎弹性希望我PUT
在/index/type/
URI 中使用它:
curl -X PUT "localhost:9200/pop/products/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Toast"
}
'
{
"_index" : "pop",
"_type" : "products",
"_id" : "1",
"_version" : 1,
"result" : "created",
"_shards" : {
"total" : 2,
"successful" : 1,
"failed" : 0
},
"_seq_no" : 0,
"_primary_term" : 1
}
我想知道如果映射类型已被删除,为什么我必须有一个指示类型的嵌套 URI?
解决方案
您必须添加_doc
到您的 put 请求调用,如下所示
curl -X PUT "localhost:9200/products/_doc/1?pretty" -H 'Content-Type: application/json' -d'
{
"name": "Toast"
}
'
在elasticsearch官方文档中提到,在7.x中删除映射类型后,您需要_doc
为文档索引,获取和删除API添加,(不代表文档类型,而是代表端点名称)
推荐阅读
- javascript - 角度 7 未按要求发送标头
- angular - PrimeNG p-table (TurboTable) pEditableRow 设置行编辑时出错
- android - 使用 Android Intent 启动带有查询字符串的 Amazon Alexa 应用程序
- sql - 有没有最简单的方法从 oracle 的电子邮件地址中只选择域名?
- javascript - 计算 li 元素的数量并添加类
- python-3.x - Python Selenium DOM Click 事件无法按预期工作
- java - Java Swing 验证?
- system-verilog - 转储 SystemVerilog 类的内存
- android - Flutter 中 ListView.builder 中的反向列表
- amazon-web-services - ALB 上的 504 网关超时