映射器解析异常根映射定义具有不受支持的参数

时间:2017-02-05 19:49:49

标签: search elasticsearch

我正在尝试使用自动完成支持成功创建索引,但我无法向其中添加数据。 请帮我解决这个问题,我在过去48小时内坚持这个错误。

请查看设置的附件

PUT http://localhost:9200/my_index/_mapping/users/ 输入:

{
  "userId": "2",
  "userFirstName": "m4",
  "userLastName": "m4",
  "userMobile": "4047534441",
  "userEmail": "test@gmail.com",
  "userSpecialization": "1:3",
  "userCityId": "6",
  "userCityName":"Hyderabad"
}

Outout:

{ "error": { "root_cause": [ { "type": "mapper_parsing_exception", "reason": "Root mapping definition has unsupported parameters: [userId : 2] [userFirstName : m4] [userLastName : m4] [userMobile : 40475341] [userEmail : test@gmail.com] [userSpecialization : 1:3] [userCityId : 6] [userCityName : Hyderabad]" } ], "type": "mapper_parsing_exception", "reason": "Root mapping definition has unsupported parameters: [userId : 2] [userFirstName : m4] [userLastName : m4] [userMobile : 40475341] [userEmail : test@gmail.com] [userSpecialization : 1:3] [userCityId : 6] [userCityName : Hyderabad]" }, "status": 400 }

设定:

{
  "my_index": {
    "aliases": {

    },
    "mappings": {
      "practices": {
        "_all": {
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        },
        "properties": {
          "practiceCity": {
            "type": "string",
            "index":"analyzed"
          },
          "practiceId": {
            "type": "long",
            "index":"not_analyzed"
          },
          "practiceName": {
            "type": "string",
            "boost": 10,
            "index":"analyzed"
          },
          "practicePhone": {
            "type": "long",
            "boost": 10,
            "index":"analyzed"
          },
          "practiceService": {
            "type": "string",
            "boost": 5,
            "index":"not_analyzed"
          }
        }
      },
      "users": {
        "_all": {
          "analyzer": "nGram_analyzer",
          "search_analyzer": "whitespace_analyzer"
        },
        "properties": {
          "userCityId": {
            "type": "long",
            "index":"not_analyzed"
          },
          "userCityName": {
            "type": "string",
            "index":"not_analyzed"
          },
          "userEmail": {
            "type": "string",
            "index":"analyzed"
          },
          "userFirstName": {
            "type": "string",
            "boost": 10,
            "index":"analyzed"
          },
          "userId": {
            "type": "long"
          },
          "userLastName": {
            "type": "string",
            "boost": 10,
            "index":"not_analyzed"
          },
          "userMobile": {
            "type": "string",
            "index":"analyzed"
          },
          "userSpecialization": {
            "type": "string",
            "boost": 5,
            "index":"not_analyzed"
          }
        }
      }
    },
    "settings": {
      "index": {
        "analysis": {
          "filter": {
            "nGram_filter": {
              "max_gram": "20",
              "type": "nGram",
              "min_gram": "3",
              "token_chars": [
                "letter",
                "digit",
                "punctuation",
                "symbol"
              ]
            }
          },
          "analyzer": {
            "nGram_analyzer": {
              "type": "custom",
              "filter": [
                "lowercase",
                "asciifolding",
                "nGram_filter"
              ],
              "tokenizer": "whitespace"
            },
            "whitespace_analyzer": {
              "type": "custom",
              "filter": [
                "lowercase",
                "asciifolding"
              ],
              "tokenizer": "whitespace"
            }
          }
        },
        "number_of_replicas": "1",
        "number_of_shards": "5"
      }
    }
  }
}

1 个答案:

答案 0 :(得分:1)

您用于索引新文档的网址错误。 _mapping端点用于管理映射类型,而不是用于索引文档。

使用这个,它会起作用。

PUT http://localhost:9200/my_index/users/2
{
  "userId": "2",
  "userFirstName": "m4",
  "userLastName": "m4",
  "userMobile": "4047534441",
  "userEmail": "test@gmail.com",
  "userSpecialization": "1:3",
  "userCityId": "6",
  "userCityName":"Hyderabad"
}