无法为带有错误消息的索引创建映射设置

时间:2019-04-04 06:00:21

标签: elasticsearch kibana

我一直在尝试为索引进行映射,并且出现了这些错误消息。

顺便说一句,我正在使用最新版本的Elasticsearch-Kibana 6.7

我尝试阅读文档并尝试编辑查询,但仍然无法正常工作。

PUT employee-details
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "type": "custom",
          "filter": [
            "lowercase"
          ],
          "tokenizer": "whitespace"
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "dynamic": "strict",
      "properties": {
        "EmpUserID": {
          "type": "integer"
        },
        "EmpName": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        },
        "Age": {
          "type": "integer"
        },
        "Gender": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        },
        "Address": {
          "type": "nested",
          "properties": {
            "AddressID": {
              "type": "integer"
            }
          },
            "AddressNumber": {
              "type": "integer"
            },
            "Location": {
              "type": "object",
              "properties": {
                "LocationID": {
                  "type": "integer"
              },
                "LocationName": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "LocationCode": {
                 "type": "text",
                 "fields": {
                   "keyword": {
                     "type": "keyword"
                  }
                }
              },
                "AddressLine1": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "AddressLine2": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "CityName": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "StateCode": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "StateName": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "keyword": {
                    "type": "keyword"
                  }
                },
                "CountryName": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                }
            }
          }
        }
      },
        "LastUpdateTimeStamp": {
          "type": "date",
          "format": "MM/dd/yyyy hh:mm a z",
          "fields": {
            "text": {
              "type": "text",
              "analyzer": "my_analyzer"
            }
          }
        }
    }
  }
}

我收到此错误消息, 我不知道这件事发生了什么。

{
  "error": {
    "root_cause": [
      {
        "type": "mapper_parsing_exception",
        "reason": "Mapping definition for [Address] has unsupported parameters:  [AddressNumber : {type=integer}] [Location : {type=object, properties={AddressLine2={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, AddressLine1={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, CountryName={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, StateName={analyzer=my_analyzer, type=text, keyword={type=keyword}}, LocationID={type=integer}, LocationCode={type=text, fields={keyword={type=keyword}}}, StateCode={type=text, fields={keyword={type=keyword}}}, CityName={type=text, fields={keyword={type=keyword}}}, LocationName={type=text, fields={keyword={type=keyword}}}}}]"
      }
    ],
    "type": "mapper_parsing_exception",
    "reason": "Failed to parse mapping [doc]: Mapping definition for [Address] has unsupported parameters:  [AddressNumber : {type=integer}] [Location : {type=object, properties={AddressLine2={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, AddressLine1={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, CountryName={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, StateName={analyzer=my_analyzer, type=text, keyword={type=keyword}}, LocationID={type=integer}, LocationCode={type=text, fields={keyword={type=keyword}}}, StateCode={type=text, fields={keyword={type=keyword}}}, CityName={type=text, fields={keyword={type=keyword}}}, LocationName={type=text, fields={keyword={type=keyword}}}}}]",
    "caused_by": {
      "type": "mapper_parsing_exception",
      "reason": "Mapping definition for [Address] has unsupported parameters:  [AddressNumber : {type=integer}] [Location : {type=object, properties={AddressLine2={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, AddressLine1={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, CountryName={analyzer=my_analyzer, type=text, fields={keyword={type=keyword}}}, StateName={analyzer=my_analyzer, type=text, keyword={type=keyword}}, LocationID={type=integer}, LocationCode={type=text, fields={keyword={type=keyword}}}, StateCode={type=text, fields={keyword={type=keyword}}}, CityName={type=text, fields={keyword={type=keyword}}}, LocationName={type=text, fields={keyword={type=keyword}}}}}]"
    }
  },
  "status": 400
}

1 个答案:

答案 0 :(得分:1)

您的json有一些语法错误。这是更正的:

{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_analyzer": {
          "type": "custom",
          "filter": [
            "lowercase"
          ],
          "tokenizer": "whitespace"
        }
      }
    }
  },
  "mappings": {
    "doc": {
      "dynamic": "strict",
      "properties": {
        "EmpUserID": {
          "type": "integer"
        },
        "EmpName": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        },
        "Age": {
          "type": "integer"
        },
        "Gender": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        },
        "Address": {
          "type": "nested",
          "properties": {
            "AddressID": {
              "type": "integer"
            },
            "AddressNumber": {         <---------- fields here on wards were outside nested properties block
              "type": "integer"
            },
            "Location": {
              "type": "object",
              "properties": {
                "LocationID": {
                  "type": "integer"
                },
                "LocationName": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "LocationCode": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "AddressLine1": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "AddressLine2": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "CityName": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "StateCode": {
                  "type": "text",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "StateName": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {                  <---------- fields was missing here
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                },
                "CountryName": {
                  "type": "text",
                  "analyzer": "my_analyzer",
                  "fields": {
                    "keyword": {
                      "type": "keyword"
                    }
                  }
                }
              }
            }
          }
        },
        "LastUpdateTimeStamp": {            <--------- was outside properties block
          "type": "date",
          "format": "MM/dd/yyyy hh:mm a z",
          "fields": {
            "text": {
              "type": "text",
              "analyzer": "my_analyzer"
            }
          }
        }
      }
    }
  }
}