给定一个干净的映射,XPOST
完全适合我在elasticsearch 5.1.1上。,
GET
插入的文档
curl -XGET localhost:9200/productsapp/productdocs/_search
{"took":11,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":1.0,"hits":[{"_index":"productsapp","_type":"productdocs","_id":"AVuhXdYYUiSguAb0FsSX","_score":1.0,"_source":{ "products" : {
"sku1" : {
"sku" : "SKU-Name",
"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" }
}
}
}}]}}
它创建是在如下状态,与作为clockSpeed
类型text
的映射。
curl -XGET localhost:9200/productsapp/productdocs/_mapping?pretty=true
{
"productsapp" : {
"mappings" : {
"productdocs" : {
"properties" : {
"products" : {
"properties" : {
"232CDFDW89ENUXRB" : {
"properties" : {
"attributes" : {
"properties" : {
"clockSpeed" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"currentGeneration" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"enhancedNetworkingSupported" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"instanceFamily" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"instanceType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"licenseModel" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"location" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"locationType" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"memory" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"networkPerformance" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operatingSystem" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operation" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"physicalProcessor" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"preInstalledSw" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"processorArchitecture" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"processorFeatures" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"servicecode" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"storage" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"tenancy" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"usagetype" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"vcpu" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
},
"productFamily" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"sku" : {
"type" : "text",
"fields" : {
"keyword" : {
"type" : "keyword",
"ignore_above" : 256
}
}
}
}
}
}
}
}
}
}
}
}
可以检查映射attributes.clockSpeed
,并确保其不会搞砸了。
如果你想更新文档做XPUT
在头文件(这是AVuhXdYYUiSguAb0FsSX
)的ID,
在下面的例子中,我更新sku
场"sku name updated"
curl -XPUT localhost:9200/productsapp/productdocs/AVuhXdYYUiSguAb0FsSX -d '
{
"products" : {
"sku1" : {
"sku" : "sku name updated",
"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"
}
}
}}'
{"_index":"productsapp","_type":"productdocs","_id":"AVu5OLfHPw6Pv_3O38-V","_version":2,"result":"updated","_shards":{"total":2,"successful":1,"failed":0},"created":false}
我明白了,谢谢你的帮助! –
如果上述答案解决了您的问题,那么您可以通过接受答案来解决问题。 – avr