创建或更新索引时“类型”未更新
The `type` is not updating when creating or updating index
我是 Kibana 和 Elasticsearch 的新手。我的任务是将数据从我们的生产站点迁移到暂存站点。目前,我已经给出了创建索引的简单代码。
我已成功创建索引,但与生产站点相比,声明为 date
的 type
在我的新站点上变成了 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 的新索引。
当您在 运行 上方时,它会将 "order"、"properties"、"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"
}
}
}
]
Link 用于(映射)[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html]
我是 Kibana 和 Elasticsearch 的新手。我的任务是将数据从我们的生产站点迁移到暂存站点。目前,我已经给出了创建索引的简单代码。
我已成功创建索引,但与生产站点相比,声明为 date
的 type
在我的新站点上变成了 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 的新索引。 当您在 运行 上方时,它会将 "order"、"properties"、"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"
}
}
}
]
Link 用于(映射)[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping.html]