尝试在一个 ElasticSearch 的 index 中导入多个 type 时报错,报错信息如下:
[responseCode] => 400
[responseHeaders] => Array
(
[content-type] => application/json; charset=UTF-8
[content-length] => 355
)
[responseBody] => Array
(
[error] => Array
(
[root_cause] => Array
(
[0] => Array
(
[type] => illegal_argument_exception
[reason] => Rejecting mapping update to [shiqidu] as the final mapping would have more than 1 type: [discussion, article]
)
)
[type] => illegal_argument_exception
[reason] => Rejecting mapping update to [shiqidu] as the final mapping would have more than 1 type: [discussion, article]
)
[status] => 400
)
原因:6.0的版本不允许一个 index 下面有多个 type,并且官方说是在接下来的7.0版本中会删掉 type ,官方说明 ,搞得有点迷,看一些文章说 ElasticSearch 的 index 相当于 数据库,type 相当于 数据表,但是现在看来,如果要储存多个表的数据,还是得建立多个 index 索引。