basemkhirat / elasticsearch

The missing elasticsearch ORM for Laravel, Lumen and Native php applications
MIT License
401 stars 130 forks source link

Error "Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true" with ElasticSearch 7.3.0 #106

Closed narigone closed 4 years ago

narigone commented 5 years ago

I was getting this error when creating/updating indexes on ElasticSearch 7.3.0:

{
    "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
}

In order to fix it, I had to add a custom parameter to the putMapping method, like this:

$this->info("Creating mapping for type: {$type} in index: {$index}");

$client->indices()->putMapping([
    'index' => $index,
    'type' => $type,
    'body' => $mapping,
    'custom' => [ 
         'include_type_name' => true
    ]
]);

I was wondering if I could create a pull request so that we could set these custom parameters through the config file. Or is there something like this already on your roadmap?

basemkhirat commented 4 years ago

FIxed

Vivenco commented 4 years ago

How was this issue fixed? I still get same issue as @narigone narigone and only his suggested fix works.

narigone commented 4 years ago

@basemkhirat if you want, I can create a pull request with a fix, pulling custom parameters from config files. It can give users more power and make things a little bit more future proof. What do you say?