我正在使用 elasticsearch river 插件版本 1.3.0.4,这是这篇文章的最新版本,针对 elasticsearch 版本 1.3.2。我正在尝试创建一个 geo_point 类型的映射,但我一直没有这样做......这是我的映射:
PUT /_river/tehotels/_meta
{
"type": "jdbc",
"jdbc": {
"driver": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://localhost:3306/blah",
"user": "",
"password": "",
"sql": "select id,hotel_id,hotel_name,hotel_url,hotel_address,overview,city_id,star_rating,latitude as \"location.lat\",longitude as \"location.lon\" from agoda_hotels",
"strategy": "simple",
"autocommit": true,
"fetchsize": 10,
"max_rows": 0,
"max_retries": 3,
"max_retries_wait": "30s",
"maxbulkactions": 1000,
"maxconcurrentbulkactions": 8,
"index": "teindex8",
"type": "hotels",
"type_mapping": {
"hotels": {
"properties": {
"_id": {
"type": "long"
},
"hotel_id": {
"type": "long"
},
"hotel_name": {
"type": "string"
},
"hotel_url": {
"type": "string",
"index": "no"
},
"hotel_address": {
"type": "string",
"index": "no"
},
"overview": {
"type": "string",
"index": "no"
},
"city_id": {
"type": "long",
"index": "no"
},
"star_rating": {
"type": "float"
},
"location": {
"type": "geo_point"
}
}
}
}
}
}
但是当我运行_mapping
命令时,它显示为:
{
"teindex8": {
"mappings": {
"hotels": {
"properties": {
"city_id": {
"type": "long"
},
"hotel_address": {
"type": "string"
},
"hotel_id": {
"type": "long"
},
"hotel_name": {
"type": "string"
},
"hotel_url": {
"type": "string"
},
"id": {
"type": "long"
},
"location": {
"properties": {
"lat": {
"type": "string"
},
"lon": {
"type": "string"
}
}
},
"overview": {
"type": "string"
},
"star_rating": {
"type": "double"
}
}
}
}
}
}
请注意,“位置”不是 geo_point 类型,而是属性列表。正如怀疑的那样,当我发出查询以搜索位置时,我收到了错误:
POST /teindex8/hotels/_search
{
"query": {
"filtered": {
"filter": {
"geo_distance": {
"distance": "20 km",
"location": "13.441111, 103.858611"
}
}
}
}
}
结果:
QueryParsingException[[teindex8] failed to find geo_point field [location]];
有人知道如何解决这个问题吗?我似乎完全按照文档...