我正在尝试在单个索引中创建多个类型。例如,我试图在host
索引中创建两种类型(post
,ytb
),以便在它们之间创建父子关系。
PUT /ytb
{
"mappings": {
"post": {
"_parent": {
"type": "host"
},
"properties":{
"@timestamp": {
"type": "date"
},
"indexed": {
"type": "date"
},
"n_comments": {
"type": "long"
},
"n_harvested": {
"type": "long"
},
"n_likes": {
"type": "long"
},
"network": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"parent_id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"post_dbid": {
"type": "long"
},
"post_id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"post_netid": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"published": {
"type": "date"
}
}
},
"host": {
"properties": {
"@timestamp": {
"type": "date"
},
"@version": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"country": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"host_dbid": {
"type": "long"
},
"host_id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"host_netid": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"id": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"indexed": {
"type": "date"
},
"language": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"name": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
},
"vertical": {
"fields": {
"keyword": {
"ignore_above": 256,
"type": "keyword"
}
},
"type": "text"
}
}
}
}
}
但我遇到此错误:
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [ytb] as the final mapping would have more than 1 type: [post, host]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [ytb] as the final mapping would have more than 1 type: [post, host]"
},
"status": 400
}
更新:Elasticsearch版本:6.3.0
答案 0 :(得分:7)
如果您的ES 5.6或更高版本,则需要阅读。总而言之,从ES 6开始,将删除映射类型,并且每个索引将仅包含一种类型。
要在评论中回答您的问题,我知道另一个类似Kibana的工具(实际上是Kibana分支),该工具知道如何处理JOIN和关系数据。它被Siren Solutions称为Kibi。另请阅读blog announcement。
答案 1 :(得分:-1)
此博客非常详细,原因、缺点和解决方法:https://www.elastic.co/guide/en/elasticsearch/reference/6.1/removal-of-types.html
总结:
type
(或类似内容),以及使用自定义 type
字段的 CRUD。