jprante / elasticsearch-jdbc

JDBC importer for Elasticsearch
Apache License 2.0
2.84k stars 709 forks source link

import json data? #716

Open LxiaoGirl opened 8 years ago

LxiaoGirl commented 8 years ago

My English is not good. mysql to elastic.

es.log: [2015-12-08 19:18:04,885][DEBUG][action.bulk ] [es-02] [test][3] failed to execute bulk item (index) index {[test][website][AVGBUAhM1aX-mOAtcpcr], source["os":"Unix","server":"Apache/2.2.22 (Unix) PHP/5.3.15 with Suhosin-Patch mod_wsgi/3.3 Python/2.7.3 mod_ssl/2.2.22 OpenSSL/0.9.8r DAV/2","script":"","charset":"us-ascii","title":"","keywords":"","desc":"","page":{"result":"running"},"time":"2015-07-31T06:39:56.000+08:00"}]} org.elasticsearch.index.mapper.MapperParsingException: failed to parse [page] at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:411) at org.elasticsearch.index.mapper.object.ObjectMapper.serializeObject(ObjectMapper.java:554) at org.elasticsearch.index.mapper.object.ObjectMapper.parse(ObjectMapper.java:487) 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.prepareCreate(IndexShard.java:466) at org.elasticsearch.action.bulk.TransportShardBulkAction.shardIndexOperation(TransportShardBulkAction.java:418) at org.elasticsearch.action.bulk.TransportShardBulkAction.shardOperationOnPrimary(TransportShardBulkAction.java:148) at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$PrimaryPhase.performOnPrimary(TransportShardReplicationOperationAction.java:574) at org.elasticsearch.action.support.replication.TransportShardReplicationOperationAction$PrimaryPhase$1.doRun(TransportShardReplicationOperationAction.java:440) at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:36) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: org.elasticsearch.ElasticsearchIllegalArgumentException: unknown property [result] at org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateFieldForString(StringFieldMapper.java:331) at org.elasticsearch.index.mapper.core.StringFieldMapper.parseCreateField(StringFieldMapper.java:277) at org.elasticsearch.index.mapper.core.AbstractFieldMapper.parse(AbstractFieldMapper.java:401) ... 13 more

'page' field in mysql is {"result":"running"} so error! json_encode first?

jprante commented 8 years ago

This is not a JDBC importer issue.

The input for Elasticsearch must not be arbitrary JSON but specific designed JSON.

In your case, page is both JSON object and JSON string, which is not allowed.