我正在使用 Elasticsearch 的 MySQL JPrante JDBC River 插件来索引来自 MySQL 的数据。
在记录集中,我有字段经度(float
),纬度(float
),销(POINT
),我如何将它们预设为geo_point
在elasticsearch中被检测到?
我试过了:
curl -XPUT 'localhost:9200/_river/mysql_jdbc_river/_meta' -d '{
"type": "jdbc",
"jdbc": {
"strategy": "simple",
"driver": "com.mysql.jdbc.Driver",
"url": "jdbc:mysql://localhost:3306/somedatabase",
"user": "someuser",
"password": "somepassword",
"sql": "SELECT * FROM activities",
"poll": "30m",
"rounding": null,
"scale": 0,
"autocommit": false,
"fetchsize": 10,
"max_rows": 0,
"max_retries": 3,
"max_retries_wait": "10s",
"digesting": true,
"acksql": null,
"acksqlparams": null
},
"index": {
"index": "jdbc",
"type": "jdbc",
"bulk_size": 100,
"max_bulk_requests": 30,
"index_settings": null,
"type_mapping": {
"location_mapping": {
"properties": {
"pin": {
"type": "geo_point",
"lat_lon": true,
"store": "yes"
}
}
}
},
"versioning": false,
"acknowledge": false
}
}'
[更新 1]
这是 javanna 描述的映射名称更改为 jdbc 的错误:
[2013-05-21 13:20:58,256][WARN ][river.jdbc ] [node-0] [jdbc][mysql_jdbc_river] failed to create index [jdbc], disabling JDBC river...
org.elasticsearch.index.mapper.MapperParsingException: Failed to parse mapping definition
at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:245)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:155)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:383)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:379)
at org.elasticsearch.cluster.metadata.MetaDataMappingService$4.execute(MetaDataMappingService.java:310)
at org.elasticsearch.cluster.service.InternalClusterService$2.run(InternalClusterService.java:229)
at org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor$TieBreakingPrioritizedRunnable.run(PrioritizedEsThreadPoolExecutor.java:95)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.elasticsearch.common.jackson.core.JsonParseException: Unexpected character ('=' (code 61)): was expecting a colon to separate field name and value
at [Source: {jdbc={properties={pin={lat_lon=true, type=geo_point}}}}; line: 1, column: 7]
at org.elasticsearch.common.jackson.core.JsonParser._constructError(JsonParser.java:1378)
at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:599)
at org.elasticsearch.common.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:520)
at org.elasticsearch.common.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:616)
at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:50)
at org.elasticsearch.common.xcontent.support.XContentMapConverter.readMap(XContentMapConverter.java:70)
at org.elasticsearch.common.xcontent.support.XContentMapConverter.readOrderedMap(XContentMapConverter.java:60)
at org.elasticsearch.common.xcontent.support.AbstractXContentParser.mapOrdered(AbstractXContentParser.java:126)
at org.elasticsearch.index.mapper.DocumentMapperParser.extractMapping(DocumentMapperParser.java:243)
... 9 more
[2013-05-21 13:20:58,264][INFO ][cluster.metadata ] [node-0] [_river] update_mapping [mysql_jdbc_river] (dynamic)