Json 创建或更新索引时,`type`未更新
我是Kibana和Elasticsearch的新手。我的任务是将数据从生产站点迁移到临时站点。目前,我已经给出了创建索引的简单代码。 我已经成功地创建了索引,但与生产站点相比,声明为date的类型在我的新站点上变成了文本。我们注意到所有类型都在转换为文本,不确定是因为我们使用的是新版本的kibana 在生产现场这里Json 创建或更新索引时,`type`未更新,json,
elasticsearch,post,kibana,Json,
elasticsearch,Post,Kibana,我是Kibana和Elasticsearch的新手。我的任务是将数据从生产站点迁移到临时站点。目前,我已经给出了创建索引的简单代码。 我已经成功地创建了索引,但与生产站点相比,声明为date的类型在我的新站点上变成了文本。我们注意到所有类型都在转换为文本,不确定是因为我们使用的是新版本的kibana 在生产现场这里 "authorizationDate": { "type": "date", "ignore_malformed": true, "format": "yyyy/M
"authorizationDate": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy/MM/dd||yyyy-MM-dd"
},
这就是我在临时站点上实现的方式
POST /orders/_doc/1
{
"order": {
"properties": {
"authorization": {
"authorizationDate": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy/MM/dd||yyyy-MM-dd"
}
}
}
}
}
经检查
GET orders?pretty
订单映射中的输出
"mappings" : {
"properties" : {
"order" : {
"properties" : {
"properties" : {
"properties" : {
"authorization" : {
"properties" : {
"authorizationDate" : {
"properties" : {
"format" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"ignore_malformed" : {
"type" : "boolean"
},
"type" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
}
}
}
},
类型变为文本而不是日期,并且不记录日期格式
提前感谢。POST/orders/\u doc/1-这将创建一个名为orders的新索引,其中包含默认的推断映射。 当您在上面运行时,它正在处理顺序、属性,忽略格式错误的字段,而不是映射的一部分。因此,您可以在下面的输出映射中看到多个嵌套属性
"properties" : {
"properties" : {
"properties" : {
要首先创建新映射,应运行
PUT orders ---> create a new index named orders
{
"mappings": {
"properties": {
"authorization": {
"type": "object", --->should be object/nested was not present in your quest
"properties": {
"authorizationDate": {
"type": "date",
"ignore_malformed": true,
"format": "yyyy/MM/dd||yyyy-MM-dd"
}
}
}
}
}
}
然后使用
POST /orders/_doc/1
{
"authorization":{
"authorizationDate":"2019-01-01"
}
}
将给出以下数据
[
{
"_index" : "orders12",
"_type" : "_doc",
"_id" : "1",
"_score" : 1.0,
"_source" : {
"authorization" : {
"authorizationDate" : "2019-01-01"
}
}
}
]
映射链接[感谢您的清晰解释。我现在明白了。