我有一个单一类型的索引。现在,我计划启用“index.mapping.single_type”,并触发了以下API使其实现,并收到以下错误。
顺便说一句,我在应用上述API之前关闭了索引。
语法是否有问题或不允许使用。
PUT testindex1/_settings
{
"settings": {
"index.mapping.single_type": true
}
}
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "final testindex1 setting [index.mapping.single_type], not updateable"
}
],
"type": "illegal_argument_exception",
"reason": "final testindex1 setting [index.mapping.single_type], not updateable"
},
"status": 400
}
最佳答案
即使关闭索引,某些设置也无法动态更新,index.number_of_shards
也是此类设置之一,它们称为final
设置,而您的index.mapping.single_type
也是final
设置,即使在您的错误消息中也提到了这一点,我将设置的final
部分加粗为区分它。
final testindex1 setting [index.mapping.single_type], not updateable
您可以使用Elasticsearch源代码更好地理解它。
org.elasticsearch.common.settings.Setting
类定义设置的类型,请参见下面的final
设置说明。/** * mark this setting as final, not updateable even when the context is not dynamic * ie. Setting this property on an index scoped setting will fail update when the index is closed */ Final,
您可以在Elasticsearch中为上面的代码检查this line,这将解释更多,下面的代码显示此
final
类型用于创建number of primary shard
设置。Setting.intSetting(SETTING_NUMBER_OF_SHARDS, 1, 1, maxNumShards, Property.IndexScope, Property.Final);
希望您理解,现在出现错误的原因和它看起来像您必须重新索引哪个新设置的数据。
关于elasticsearch - 无法设置index.mapping.single_type:对索引为true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60963402/