elasticsearch - 使用json文件和curl命令将数据导入elasticsearch索引
问题描述
我正在尝试使用 curl 命令将位于 json 文件中的数据导入弹性搜索索引。
正在使用kibana
如下方式创建索引
PUT employees
{
"mappings" : {
"properties":{
"fields": {
"properties": {
"id": {"type": "text"},
"nom": {"type": "text"},
"prenom": {"type": "text"},
"sexe": {"type": "text"},
"socials": {
"properties": {
"name": {"type": "text"},
"url": {"type": "text"}
}
},
}
}
}
}
}
我正在运行以下命令来导入数据
curl -XPUT -H "Content-Type: application/json" localhost:9200/_bulk --data-binary @users.json
该users.json
文件包含如下表示的数据
{"index": {"_index": "users", "_type": "user", "_id": 1}}
{"fields": {"id": "5fe60ae52b40e53609c803ec","nom": "Jessica","prenom": "Herrera","aboutMe": "anim","socials": [{"name": "faacebook","url": "https://www.facebook.com/profile?id=5445546"},{"name": "linkedin","url": "https://www.linkedin.com/profile?id=5445546"}],"affiliations": [{"organisation": "ANARCO","equipe": "developpement","pays": "Russian Federation","dateD": "2013-06-03T00:00:00Z" ,"dateF": "2013-06-03T00:00:00Z" }]}}
这是我得到的错误
"type":"illegal_argument_exception","reason":"Rejecting mapping update to [users] as the final mapping would have more than 1 type
我已经阅读了很多资源,但仍然无法理解我所缺少的。
解决方案
"type":"illegal_argument_exception","reason":"拒绝对 [users] 的映射更新,因为最终映射将有超过 1 种类型
由于Elasticsearch 6.x中的重大更改(其中不推荐使用映射类型),您会收到上述错误。
在 Elasticsearch 7.0.0 或更高版本中创建的索引不再接受 默认映射。在 6.x 中创建的索引将继续像以前在 Elasticsearch 6.x 中一样运行。类型在 7.0 的 API 中被弃用,对索引创建、放置映射、获取映射、放置模板、获取模板和获取字段映射 API 进行了重大更改。
您需要将 JSON 修改为 -
{"index": {"_index": "users", "_id": 1}}
{"fields": {"id": "5fe60ae52b40e53609c803ec","nom": "Jessica","prenom": "Herrera","aboutMe": "anim","socials": [{"name": "faacebook","url": "https://www.facebook.com/profile?id=5445546"},{"name": "linkedin","url": "https://www.linkedin.com/profile?id=5445546"}],"affiliations": [{"organisation": "ANARCO","equipe": "developpement","pays": "Russian Federation","dateD": "2013-06-03T00:00:00Z" ,"dateF": "2013-06-03T00:00:00Z" }]}}
推荐阅读
- kubernetes - 如何在 Kubernetes 中获取 pod 的文件/它们的位置?
- docker - Nginx + Otrs 重定向子文件夹(docker)
- php - 我正在尝试从经过身份验证的用户配置文件的用户表中传递用户的 ID
- performance - Vue 3:如何实现修改 DOM 中所有输入字段的功能?
- javascript - Mulitdatepicker - 从数组中设置的日期中删除 .ui-state-highlight
- xml - 来自数组响应的 Oracle 12c PLSQL SOAP EXTRACTVALUE
- awk - 仅在下一列中更改与另一个模式匹配的模式
- utf-8 - Mulesoft SFTP 使用 BOM 写入 UTF-8 编码的 .csv 文件
- node.js - nodemailer SMTP 服务器连接问题(错误:连接 ETIMEDOUT)但它适用于不在我的另一个系统
- ios - 1.有没有办法在ios中收集双卡运营商信息(物理+ esim)?