【发布时间】:2016-10-26 21:31:09
【问题描述】:
我正在尝试关注documentation for geo_points。 为此,我创建了一个名为“城市”的索引
curl -X POST -H "Cache-Control: no-cache" -H -d '{
"mappings": {
"cities": {
"properties": {
"name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"location":{
"type": "geo_point"
}
}
}
}
}' "http://192.168.0.76:9200/cities"
我现在正尝试使用以下请求插入文档:
curl -X POST -H "Cache-Control: no-cache" -d '{
"name": "Amsterdam",
"location": "52.3702,4.8952"
}' "http://192.168.0.76:9200/cities/properties?pretty"
然而,这会返回以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "failed to parse"
}
],
"type": "mapper_parsing_exception",
"reason": "failed to parse",
"caused_by": {
"type": "illegal_state_exception",
"reason": "Mixing up field types: class org.elasticsearch.index.mapper.core.StringFieldMapper$StringFieldType != class org.elasticsearch.index.mapper.geo.BaseGeoPointFieldMapper$GeoPointFieldType on field location"
}
},
"status": 400
}
对我来说,这似乎很奇怪,因为文档指出我应该能够使用字符串表示法插入文档:
将 location 字段定义为 geo_point,我们可以继续 包含纬度/经度对的索引文档,可以是 格式化为字符串、数组或对象:
字符串表示,带有“lat,lon”。
我做错了什么?
【问题讨论】:
标签: elasticsearch