Elasticquent icon indicating copy to clipboard operation
Elasticquent copied to clipboard

mapper_parsing_exception

Open sharathm89 opened this issue 5 years ago • 9 comments

I am using ES through docker using below 2 commands..

docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.1

docker run -d --rm --name search-aol -p 9200:9200 -p 9300:9300 -e discovery.type=single-node -e http.cors.enabled=true -e http.cors.allow-origin=http://localhost:1358,http://127.0.0.1:1358 -e http.cors.allow-headers=X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization -e http.cors.allow-credentials=true -d docker.elastic.co/elasticsearch/elasticsearch:7.1.1

Just followed this tutorial -> Click Here

My Model is

class Article extends Model
{
    use ElasticquentTrait;

    protected $fillable = ['title', 'body', 'tags'];

    protected $mappingProperties = array(
      'title' => [
        'type' => 'text',
        "analyzer" => "standard",
      ],
      'body' => [
        'type' => 'text',
        "analyzer" => "standard",
      ],
      'tags' => [
        'type' => 'text',
        "analyzer" => "standard",
      ],
    );   

    function getTypeName()
    {
        return 'article_type_name';
    }
}

When trying create index gives an exception

use App\Article;

Route::get('/test', function () {
    Article::createIndex($shards = null, $replicas = null);

    Article::putMapping($ignoreConflicts = true);

    Article::addAllToIndex();

    return view('welcome');
});

elasticquent.php

<?php

return array(

    'config' => [
        'hosts'     => ['localhost:9200'],
        'retries'   => 1,
    ],

    'default_index' => 'laravel_test',

);

My Packages

"php": "^7.1.3", "elasticquent/elasticquent": "dev-master", "elasticsearch/elasticsearch": "6.1.0",

Below is the error being throw when creating index

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Root mapping definition has unsupported parameters:  [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters:  [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Root mapping definition has unsupported parameters:  [article_type_name : {_source={enabled=true}, properties={title={analyzer=standard, type=text}, body={analyzer=standard, type=text}, tags={analyzer=standard, type=text}}}]"
    }
  },
  "status": 400
}

sharathm89 avatar Jun 25 '19 04:06 sharathm89

I have the same error and I don't know what else to do

bucalexis avatar Jul 22 '19 03:07 bucalexis

See #169. I haven't used 7.x yet, but setting getTypeName() to return "_doc" or "" should work.

function getTypeName()
{
    return '_doc';
}

coffeeburrito avatar Jul 22 '19 13:07 coffeeburrito

I am facing exact same issue. Did anyone found a solution to this?

rohan5894 avatar Aug 13 '19 16:08 rohan5894

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Root mapping definition has unsupported parameters: [elastic_questions : {_source={enabled=true}, properties={product_isbn={analyzer=standard, type=keyword}, customer_question={analyzer=standard, type=text}, product_upc={analyzer=standard, type=keyword}, product_mpn={analyzer=standard, type=keyword}, original_product_id={analyzer=standard, type=integer}, product_ean={analyzer=standard, type=keyword}}}]"}]

rohan5894 avatar Aug 13 '19 16:08 rohan5894

See #169. I haven't used 7.x yet, but setting getTypeName() to return "_doc" or "" should work.

function getTypeName()
{
    return '_doc';
}

i met "{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."}],"type":"illegal_argument_exception","reason":"The mapping definition cannot be nested under a type [_doc] unless include_type_name is set to true."},"status":400}" when change getTypeName to _doc, how can i set include_type_name to elastic request.

ngocnkd-1407 avatar Aug 26 '19 07:08 ngocnkd-1407

I am facing the same issue but still I didn't get answer please explain it in a detail way and explain where we need to change

mbilal998 avatar Aug 30 '19 12:08 mbilal998

Hi guys, I have met this issues on ES 7.6.2 are there any solutions?

victorvusg avatar Apr 11 '20 09:04 victorvusg

I have the same issue, my fix was delete setType($type); in the file vendor/elasticsearch/elasticsearch/src/Elasticsearch/Namespaces/IndicesNamespace.php at line 287, take care if you run composer update your change will be lost.

maganius avatar Aug 23 '20 23:08 maganius

Hello,

Is there a solution to this problem?

piep14 avatar Feb 09 '22 01:02 piep14