Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation Failed: 1: mapping type is missing; in elasticsearch

I'm was an error same this questuion. As the answer of this question i'm trying to set correct url to PUT index mapping, but it's not work on my instance:

$ cat mapping.json | http PUT myhost:9200/acastest/_mapping 

result:

HTTP/1.1 400 Bad Request
Content-Length: 247
Content-Type: application/json; charset=UTF-8

{
    "error": {
        "reason": "Validation Failed: 1: mapping type is missing;", 
        "root_cause": [
            {
                "reason": "Validation Failed: 1: mapping type is missing;", 
                "type": "action_request_validation_exception"
            }
        ], 
        "type": "action_request_validation_exception"
    }, 
    "status": 400
}

and trying with this:

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 

result:

HTTP/1.1 400 Bad Request
Content-Length: 3969
Content-Type: application/json; charset=UTF-8

{
    "error": {
        "reason": "Root mapping definition has unsupported parameters:  [mappings : {articles={properties={category_en={type=string, index=not_analyzed},blah blah blah", 
        "root_cause": [
            {
                "reason": "Root mapping definition has unsupported parameters:  [mappings : {articles={properties={category_en={type=string, index=not_analyzed}, category_fa={blahblah blah", 
                "type": "mapper_parsing_exception"
            }
        ], 
        "type": "mapper_parsing_exception"
    }, 
    "status": 400
}

Elasticsearch config:

"version": {

    "number": "2.1.1",
    "build_hash": "40e2c53a6b6c2972b3d13846e450e66f4375bd71",
    "build_timestamp": "2015-12-15T13:05:55Z",
    "build_snapshot": false,
    "lucene_version": "5.3.1"

},

and my mapping file like this:

{ 
    "mappings": {
            "articles": {
                "properties": {
                    "category_en": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "category_fa": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    blah
                    blah
                    blah
                }
            }
        }
}

To see complete mapping file, check this How can i fix it?

like image 302
Vahid Kharazi Avatar asked Mar 05 '16 12:03

Vahid Kharazi


2 Answers

You have two solutions:

A. If you want to run

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 

You need to change your mapping.json file like this:

    { 
        "articles": {
            "properties": {
                "category_en": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "category_fa": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                blah
                blah
                blah
            }
        }
    }

B. Or you can keep your mapping.json file like it is now, but then you need to run the following command instead:

$ cat mapping.json | http PUT myhost:9200/acastest 
like image 84
Val Avatar answered Sep 24 '22 09:09

Val


My solution:

change URL to:

http://myhost:9200/acastest/_mapping/articles 

Changing mapping.json to:

{
    "articles": {
        "properties": {
            "category_en": {
                "type": "string",
                "index": "not_analyzed"
            },
            "category_fa": {
                "type": "string",
                "index": "not_analyzed"
            },
            blah
            blah
            blah
        }
    }
}
like image 32
berniey Avatar answered Sep 26 '22 09:09

berniey