验证失败:1:映射类型丢失;在Elasticsearch中

2 8*_*2 8 7 lucene elasticsearch

我是一个错误相同此questuion。作为此问题的答案,我正在尝试为PUT索引映射设置正确的url,但不适用于我的实例:

$ cat mapping.json | http PUT myhost:9200/acastest/_mapping 
Run Code Online (Sandbox Code Playgroud)

结果:

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
}
Run Code Online (Sandbox Code Playgroud)

并尝试与此:

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 
Run Code Online (Sandbox Code Playgroud)

结果:

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
}
Run Code Online (Sandbox Code Playgroud)

Elasticsearch配置:

"version": {

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

},
Run Code Online (Sandbox Code Playgroud)

和我的映射文件是这样的:

{ 
    "mappings": {
            "articles": {
                "properties": {
                    "category_en": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    "category_fa": {
                        "type": "string",
                        "index": "not_analyzed"
                    },
                    blah
                    blah
                    blah
                }
            }
        }
}
Run Code Online (Sandbox Code Playgroud)

要查看完整的映射文件,请选中此 我该如何解决?

Val*_*Val 4

您有两种解决方案:

A. 如果你想跑步

$ cat mapping.json | http PUT myhost:9200/acastest/articles/_mapping 
Run Code Online (Sandbox Code Playgroud)

您需要mapping.json像这样更改您的文件:

    { 
        "articles": {
            "properties": {
                "category_en": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                "category_fa": {
                    "type": "string",
                    "index": "not_analyzed"
                },
                blah
                blah
                blah
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)

B. 或者您可以mapping.json像现在一样保留文件,但您需要运行以下命令:

$ cat mapping.json | http PUT myhost:9200/acastest 
Run Code Online (Sandbox Code Playgroud)