【发布时间】:2020-04-03 15:23:49
【问题描述】:
我想在 elasticsearch 上创建一个索引,并且我想创建一个映射。
我对映射的理解是,这是插入数据以定义字段类型之前的可选步骤。
索引创建:
curl -X PUT "localhost:9200/idx5"
映射创建:
curl -X PUT "localhost:9200/idx5/_mapping" -H 'Content-Type: application/json' -d'
{
"properties": {
"element_type": {
"type": "keyword"
}
}
}
'
现在,我尝试在索引中插入数据时出现此错误
[type] => illegal_argument_exception
[reason] => Rejecting mapping update to [idx5] as the final mapping would have more than 1 type: [_doc, doc]
如果我不创建映射,我没有错误。
有什么想法吗?
谢谢
** 编辑 **
弹性搜索版本:6.2.4
** 编辑 **
这是我尝试插入数据的方式:
curl -X POST http://localhost:9200/idx5/doc/ -H 'Content-Type: application/json' -d'{
"id" : "1234",
"element_type": "TYPE1",
"title" : "test"
}
'
【问题讨论】:
-
你用的是哪个es版本?
-
6.2.4 查看我的编辑
-
谢谢,正在调查中
-
我已经添加了我尝试插入数据的方式
-
谢谢,你能用这个网址
http://localhost:9200/idx5/_doc/添加数据吗
标签: elasticsearch elasticsearch-mapping