我正在使用https://github.com/basemkhirat/elasticsearch软件包。
在es.php文件中,我在indices >>]下'indices' => [
'media' => [
'settings' => [
'number_of_shards' => 2,
'number_of_replicas' => 2,
'analysis' => [
'filter' => [
'custom_english_stemmer' => [
'type' => "stemmer",
'name' => "english"
],
"english_stop" => [
'type' => "stop",
'stopwords' => "_english_"
]
],
"analyzer" => [
'custom_lowercase_analyzer' => [
// 'type' => 'custom',
'tokenizer' => 'standard',
'filter' => [
'lowercase',
'english_stop',
"custom_english_stemmer"
]
]
]
]
],
'mappings' => [
'properties' => [
'id' => [
'type' => 'long',
'index' => false,
'doc_values' => false,
],
'title' => [
'type' => 'text',
"analyzer" => 'custom_lowercase_analyzer'
]
]
]
]
]
现在执行php artisan es:indices:create
时会创建设置,但映射失败并显示错误消息。
{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
}
],
"type": "illegal_argument_exception",
"reason": "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true."
},
"status": 400
}
如何解决此问题
我正在使用https://github.com/basemkhirat/elasticsearch软件包。在es.php文件中,我有以下索引'indices'=> [''media'=> ['settings'=> ['...
您正在创建索引代码中提供类型,因为不建议使用类型,请从索引中删除media
类型,有关更多信息,请参见the removal of types。>
[请注意,在Elasticsearch 7.X中,您仍然可以通过具有types
参数来获得include_type_name
的方法,但由于在即将发布的Elasticsearch 8.X中将完全删除types
,因此它不是首选方法。
为了在您的情况下使用具有自定义type
的索引来创建索引,例如media
,您需要将include_type_name=true
传递给索引创建,模板和映射API,如this official ES blog中所述