ElasticSearch非法参数异常 [英] ElasticSearch Illegal Argument Exception

查看:127
本文介绍了ElasticSearch非法参数异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Ubuntu 16.04上使用Elasticsearch的最新版本,在将数据放入其中时遇到了一个小问题.

I'm using Elasticsearch latest version on Ubuntu 16.04 and I'm having a little issue on putting data on it.

这是我的json文档(相关部分)

here is my json document (relevant part of it)

{   "products" : {
    "232CDFDW89ENUXRB" : {
        "sku" : "232CDFDW89ENUXRB",
        "productFamily" : "Compute Instance",
        "attributes" : {
            "servicecode" : "AmazonEC2",
            "location" : "US East (N. Virginia)",
            "locationType" : "AWS Region",
            "instanceType" : "d2.8xlarge",
            "currentGeneration" : "Yes",
            "instanceFamily" : "Storage optimized",
            "vcpu" : "36",
            "physicalProcessor" : "Intel Xeon E5-2676v3 (Haswell)",
            "clockSpeed" : "2.4 GHz",
            "memory" : "244 GiB",
            "storage" : "24 x 2000 HDD",
            "networkPerformance" : "10 Gigabit",
            "processorArchitecture" : "64-bit",
            "tenancy" : "Host",
            "operatingSystem" : "Linux",
            "licenseModel" : "No License required",
            "usagetype" : "HostBoxUsage:d2.8xlarge",
            "operation" : "RunInstances",
            "enhancedNetworkingSupported" : "Yes",
            "preInstalledSw" : "NA",
            "processorFeatures" : "Intel AVX; Intel AVX2; Intel Turbo" }
        }
    }   
}

这是当我尝试"PUT http://localhost:9200/aws 时来自ES的返回响应"

and here's the returning response from ES when i try "PUT http://localhost:9200/aws"

{ "error": {
"root_cause": [
  {
    "type": "illegal_argument_exception",
    "reason": "unknown setting [index.products.232CDFDW89ENUXRB.attributes.clockSpeed] please check that any required plugins are installed, or check the breaking changes documentation for removed settings"
  }
],
"type": "illegal_argument_exception",
"reason": "unknown setting [index.products.232CDFDW89ENUXRB.attributes.clockSpeed] please check that any required plugins are installed, or check the breaking changes documentation for removed settings" }, "status": 400 }

在我看来,ES认为"clockSpeed"是某种设置...?我希望使用动态映射来加快过程,而不是先映射所有文档,然后将其导入ES.
有什么建议吗?

Seems to me ES thinks that "clockSpeed" is some sort of setting...? I was hoping to use dynamic mapping to speed the process up instead of first mapping all the document and then importing it in ES.
Any suggestion?

推荐答案

问题是您在通过为文档建立索引时缺少文档类型 document id PUT http://localhost:9200/aws 命令.

The issue is you are missing document type and document id while indexing a document through PUT http://localhost:9200/aws command.

索引文档的正确方法是:

Proper way to index document is:

POST my-index/my-type/my-id-1
{
  "name": "kibana"
}

即,您必须提供文档类型(此处为my-type)和 document id (此处为my-id-1).请注意,此处的文档ID是可选的,因此,如果您不提供文档ID,那么elasticsearch会为您创建一个字母数字ID.

i.e You have to provide document type (here my-type) and document id (here my-id-1). Note that document id is optional here so if you don't provide one then elasticsearch create one alphanumeric id for you.

其他两种方式为文档建立索引:

Other couple of ways indexing a doc:

POST my-index/my-type
{
  "name": "kibana"
}

//if you want to index document through PUT then you must provide document id
PUT my-index/my-type/my-id-1
{
  "name": "kibana"
}

注意:如果禁用了自动创建索引,则必须在创建文档索引之前创建索引.

Note: If automatic index creation is disabled then you have to create index before indexing documents.

这篇关于ElasticSearch非法参数异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆