我使用elasticsearch-river-jdbc从mysql导入数据,我有一个字符串字段,此字段中的数据是一个json字符串(如下所示:'[{“id”:1}]'),i想要将字符串映射到elasticsearch中的对象,有谁知道如何做到这一点?
我使用type_mappping来映射字段:
"type_mapping":
{
"postsInfo":
{"properties":
{
"forums":{
"type":"object"
}
}
}
}
但是弹性搜索会抛出异常:
org.elasticsearch.index.mapper.MapperParsingException: object mapping for [postsInfo] tried to parse field [forums] as object, but got EOF, has a concrete value been provided to it?
at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:495)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:544)
at org.elasticsearch.index.mapper.DocumentMapper.parse(DocumentMapper.java:493)
at org.elasticsearch.index.shard.IndexShard.prepareIndex(IndexShard.java:480)
at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:423)
at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:149)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction.performOnPrimary(TransportShardReplicationOperationAction.java:515)
at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$AsyncShardOperationAction$1.run(TransportShardReplicationOperationAction.java:422)
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:745)
我有谷歌很长一段时间,但没有找到解决方案,任何人都可以帮助我吗?
导致异常的文档:
{
"postsId":100,
"gmtCreate":"2015-08-17T16:38:54.000+08:00",
"gmtModified":"2015-12-10T19:38:17.000+08:00",
"status":1,
"postsType":1,
"title":"test",
"userId":123,
"userIconPath":"/user/avatar/123.png",
"province":null,
"city":null,
"district":null,
"recommendCover":null,
"location":{
"lat":0,
"lon":0
},
"lat":null,
"lng":null,
"forums":"[{"id":18,"name":"官方"}]",
"subForums":"[{"id":19,"name":"评测"}]",
"isDeleted":0,
"weight":0,
"dayGroup":"2015-08-17",
"content":"test"
}