I am using https://github.com/basemkhirat/elasticsearch package.
In es.php file i have below 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'
]
]
]
]
]
Now when php artisan es:indices:create
is executed settings is created but mapping fails with an error message.
{
"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
}
How to fix this issue
You are providing type in your create index code, remove media
type from your index, as types are deprecated, see the removal of types for more information.
Please note in Elasticsearch 7.X still you can do some workaround to have custom types
by having include_type_name
param but it's not preferred as types
will be totally removed in upcoming Elasticsearch 8.X.
In order to use create your index with custom type
like media
(default is _doc
mentioned in your screen-shot) in your case, you need to pass include_type_name=true
to index creation, template, and mappings APIs as mentioned in this official ES blog