gpt4 book ai didi

json - 创建或更新索引时 `type`不更新

转载 作者:行者123 更新时间:2023-12-03 01:26:33 25 4
gpt4 key购买 nike

我是Kibana和Elasticsearch的新手。我的任务是将数据从生产站点迁移到暂存。目前,我已经给出了创建索引的简单代码。
我已经成功创建了索引,但是与生产站点相比,声明为typedate在我的新站点上变成了text。我们注意到所有类型都将转换为text,但不确定是因为我们使用的是新版本的kibana。

在生产现场...

"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
}
}
}
}
}
}
}
}
}
}
}
}
},
type变为文本而不是日期,并且不记录日期格式。

提前致谢。

最佳答案

POST / orders / _doc / 1-这将创建一个带有默认推断映射的名为orders的新索引。
当您在上方运行时,它将“顺序”,“属性”,“ignore_malformed”视为不属于映射的字段。因此,您可以在下面的输出映射中看到多个嵌套属性。

"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"
}
}
}
]

(映射)的链接[ https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html]

关于json - 创建或更新索引时 `type`不更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58021615/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com