2016-03-05 480 views
2

我是一個錯誤相同this questuion。 由於這個問題,我正在嘗試設置正確的URL把索引映射的答案,但它不是我的情況下工作:驗證失敗:1:映射類型丟失;在elasticsearch

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

結果:

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 
} 

,並試圖用這樣的:

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

結果:

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配置:

"version": { 

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

}, 

和我的映射文件是這樣的:

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

要查看完整的映射文件,檢查this 我怎樣才能解決這個問題?

+1

您需要刪除' 「映射」 和''有 「文章」 '在'mapping.json'文件的頂層。 – Val

回答

1

有兩種解決方法:

答:如果你想運行

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

你需要改變你的mapping.json文件是這樣的:

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

B.或者你可以保持您的mapping.json文件現在是這樣,但是您需要運行以下命令:

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

我的解決辦法:

變化網址:

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

更改mapping.josn到:

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