我正在Ubuntu 16.04上使用最新版本的Elasticsearch,但在将数据放到上面时遇到了一个小问题。
这是我的json文档(相关部分)
{ "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返回的响应
{ "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。 有什么建议吗?
问题是您丢失了,document type并且document id在通过PUT http://localhost:9200/aws命令索引文档时。
document type
document id
PUT http://localhost:9200/aws
索引文档的正确方法是:
POST my-index/my-type/my-id-1 { "name": "kibana" }
即,您必须提供document type(此处为my-type)和document id(此处为my- id-1)。请注意,此处的文档ID是可选的,因此,如果您不提供文档ID,则elasticsearch为您创建一个字母数字ID。
索引文档的其他几种方法:
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" }
注意: 如果禁用了自动索引创建,则必须在索引文档之前创建索引。