shoaib1992
shoaib1992

Reputation: 420

mapper_parsing_exception while creating an index in elastic search 6.4.0

I am trying to create an Elasticsearch index using below JSON which is causing an exception. The current version of elastic search I'm using is 6.4.0.

The exception says Root mapping definition has unsupported parameters. Not sure what is the problem

{
    "settings": {
        "analysis": {
            "analyzer": {
                "my_analyzer": {
                    "filter": [
                        "lowercase"
                    ],
                    "char_filter": [
                        "html_strip"
                    ],
                    "type": "custom",
                    "tokenizer": "whitespace"
                }
            }
        }
    },
    "mappings" :{
        "properties" :{
            "title" :{
                "type" : "text",
                "analyzer" : "my_analyzer"
            }
        }
    }
}

This is causing below exception:

{
    "error": {
        "root_cause": [
            {
                "type": "mapper_parsing_exception",
                "reason": "Root mapping definition has unsupported parameters:  [title : {analyzer=my_analyzer, type=text}]"
            }
        ],
        "type": "mapper_parsing_exception",
        "reason": "Failed to parse mapping [properties]: Root mapping definition has unsupported parameters:  [title : {analyzer=my_analyzer, type=text}]",
        "caused_by": {
            "type": "mapper_parsing_exception",
            "reason": "Root mapping definition has unsupported parameters:  [title : {analyzer=my_analyzer, type=text}]"
        }
    },
    "status": 400
}

Upvotes: 0

Views: 1444

Answers (1)

Amit
Amit

Reputation: 32376

This is due to the fact, that you are not adding _doc in your mappings section, this is because types are deprecated and see why this is mandatory to add in Elasticsearch 6.X version as mentioned in schedule_for_removal_of_mapping_types

Please refer the Elasticsearch 6.4 official doc on how to create mappings.

To make it work, you need to add the _doc in the mapping section as below:

{
    "settings": {
        "analysis": {
            "analyzer": {
                "my_analyzer": {
                    "filter": [
                        "lowercase"
                    ],
                    "char_filter": [
                        "html_strip"
                    ],
                    "type": "custom",
                    "tokenizer": "whitespace"
                }
            }
        }
    },
    "mappings": {
        "_doc": {     // Note this, you need to add this
            "properties": {
                "title": {
                    "type": "text",
                    "analyzer": "my_analyzer"
                }
            }
        }
    }
}

Upvotes: 1

Related Questions