如何修复空白分析器错误?

时间:2015-12-18 18:03:02

标签: json elasticsearch

我尝试使用elasticdump使用以下命令导入映射:

elasticdump --input=myMapping.json --output=http://localhost:9200/myIndex --type=mapping

获得以下输出:

Fri, 18 Dec 2015 17:53:05 GMT | starting dump
Fri, 18 Dec 2015 17:53:05 GMT | got 1 objects from source file (offset: 0)
Fri, 18 Dec 2015 17:53:05 GMT | Error Emitted => {"root_cause":[{"type":"mapper_parsing_exception","reason":"analyzer [whitespace_analyzer] not found for field [_all]"}],"type":"mapper_parsing_exception","reason":"analyzer [whitespace_analyzer] not found for field [_all]"}
Fri, 18 Dec 2015 17:53:05 GMT | Total Writes: 0
Fri, 18 Dec 2015 17:53:05 GMT | dump ended with error (set phase)  => [object Object]

我已经用Google搜索了这个问题,我无法回答这个问题。有什么想法吗?

编辑:MyMapping.json

[
"{\"myIndex\":{\"mappings\":{\"favourites\":{\"_all\":{\"index_analyzer\":\"nGram_analyzer\",\"search_analyzer\":\"whitespace_analyzer\"},\"_timestamp\":{\"enabled\":true,\"store\":true},\"properties\":{\"thing\":{\"properties\":{\"type_one_id\":{\"type\":\"long\",\"include_in_all\":false},\"type_two_id\":{\"type\":\"string\"},\"type_three_id\":{\"type\":\"string\"},\"att_one\":{\"type\":\"long\"},\"att_two\":{\"type\":\"string\"},\"att_three\":{\"type\":\"long\"},\"att_four\":{\"type\":\"string\"},\"att_five\":{\"type\":\"long\"},\"att_six\":{\"type\":\"string\"},\"att_seven\":{\"type\":\"long\",\"include_in_all\":false},\"att_eight\":{\"type\":\"string\"},\"att_nine\":{\"type\":\"long\",\"include_in_all\":false},\"att_ten\":{\"type\":\"long\",\"include_in_all\":false},\"att_eleven\":{\"type\":\"long\",\"include_in_all\":false},\"att_twelve\":{\"type\":\"string\"},\"att_thirteen\":{\"type\":\"string\"},\"att_fourteen\":{\"type\":\"string\"},\"att_fifteen\":{\"type\":\"string\"},\"att_sixteen\":{\"type\":\"long\",\"include_in_all\":false},\"seventeen\":{\"type\":\"string\"},\"eighteeen\":{\"type\":\"long\",\"include_in_all\":false},\"nineteen\":{\"type\":\"long\",\"include_in_all\":false},\"twenty\":{\"type\":\"long\",\"include_in_all\":false},\"twenty_one\":{\"type\":\"long\"}}},\"uuid\":{\"type\":\"string\",\"index\":\"not_analyzed\",\"include_in_all\":false},\"versionId\":{\"type\":\"long\"},\"version_id\":{\"type\":\"long\",\"include_in_all\":false}}}}}}"
]

1 个答案:

答案 0 :(得分:2)

您首先需要定义[ { "first name": "adam", "last name": "smith" "gender": "male", "merried": "yes" "degree": "MS", "description": "any discription" }, { "first name": "anglina", "last name": "jouley" "gender": "female", "merried": "no" "degree": "PhD", "description": "any discription" }, ] nGram_analyzer,因为ES无法找到它们而导致错误,因此请创建索引(根据您的要求更改)

whitespace_analyzer

然后你的命令会起作用,这是我得到的输出

POST myIndex
{
  "settings": {
    "analysis": {
      "analyzer": {
        "nGram_analyzer": {
          "tokenizer": "standard",
          "filter": [
            "lowercase",
            "asciifolding",
            "ngram_filter"
          ]
        },
        "whitespace_analyzer": {
          "tokenizer": "whitespace"
        }
      },
      "filter": {
        "ngram_filter": {
          "type": "nGram",
          "min_gram": 2,
          "max_gram": 8
        }
      }
    }
  }
}