我试图发送数据到elasticsearch,但是遇到了一个问题,我的数字字段只显示为字符串。
步骤1.添加索引和Map
PUT http://123.com:5101/core_060619/
{
"mappings": {
"properties": {
"date": {
"type": "date",
"format": "HH:mm yyyy-MM-dd"
},
"data": {
"type": "integer"
}
}
}
}
结果:
{
"acknowledged": true,
"shards_acknowledged": true,
"index": "core_060619"
}
步骤2.添加数据
PUT http://123.com:5101/core_060619/doc/1
{
"test" : [ {
"data" : "119050300",
"date" : "00:00 2019-06-03"
} ]
}
结果:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [zyxnewcoreyxbl_060619] as the final mapping would have more than 1 type: [_doc, doc]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [zyxnewcoreyxbl_060619] as the final mapping would have more than 1 type: [_doc, doc]"
},
"status": 400
}
1条答案
按热度按时间eufgjt7s1#
Elasticsearch 6.0.0+
中不能有超过一种类型的文档。如果您将文档类型设置为doc
,则可以通过PUT http://123.com:5101/core_060619/doc/1
、PUT http://123.com:5101/core_060619/doc/2
等添加另一个文档。ElasticSearch6.+
由于我们创建了具有
doc
类型文档的Map,现在我们可以通过简单地添加/doc/_id
来添加新文档:ElasticSearch7.+
类型已删除,但您可以使用自定义字段,例如:
Removal of mapping types