Hello again,
I just upgraded to ElasticStack 5 and I'm still not able to solve this problem.
Since ESv5 brings back the 'DOT' support in field names I just moved a step ahead in the progress of mitigating this mapping issue.
Now, I can able to map the field names with 'DOT' via elasticsearch 'es.mapping.names'. But unfortunately, I can't typecast the field from 'object' to 'geo_point' data type. i.e., trying to map an object field geo_custom{"lat":"xx.xxx","lon":"yy.yyy"} to elasticsearch is throwing an error. Let me try to explain the issue again with some more details, maybe you or someone could help me in this.
Creating Table in Hive:
CREATE EXTERNAL TABLE IF NOT EXISTS test (
geo_lat string,
geo_lon string,
date string
)
ROW FORMAT SERDE 'org.elasticsearch.hadoop.hive.EsSerDe'
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler'
TBLPROPERTIES (
'es.nodes'='xx.xxx.xxx.xx',
'es.mapping.names' = 'date:@timestamp, geo_lat:geo_custom.lat, geo_lon:geo_custom.lon',
'es.resource'='xxxxx-{date:YYYY.MM.dd}'
);
^ Here I'm have my lat and lon as separate fields and mapping them into a new custom field named "geo_custom" as geo_point object as mentioned here.
Elasticsearch Template:
{
"template":"xxxxx-*",
"settings":{
"index":{
"mapping.ignore_malformed":true,
"number_of_shards":5,
"refresh_interval":"-1"
}
},
"mappings":{
"Yyyyyy":{
"properties":{
"geo_lat":{
"type":"keyword"
},
"geo_lon":{
"type":"keyword"
},
"geo_custom":{
"type":"geo_point"
},
"date":{
"type":"date",
"format":"yyyy-MM-dd"
}
}
}
}
}
^ Here I'm creating my template specifying "geo_custom" as type of "geo_point".
Hive Query:
INSERT INTO TABLE test SELECT geo['lat'],geo['lon'],date FROM source_table WHERE date='2016-11-02';
^ Hive query to insert data from HDFS to Elasticsearch table. Executing this query fails and ends with the following errors.
Error Logged Hive Console:
Error: java.lang.RuntimeException: Hive Runtime Error while closing operators: Found unrecoverable error [xx.xxx.xxx.xx:9200] returned Bad Request(400) - Could not dynamically add mapping for field [geo_custom.lat]. Existing mapping for [geo_custom] must be of type object but found [geo_point].; Bailing out..
at org.apache.hadoop.hive.ql.exec.mr.ExecReducer.close(ExecReducer.java:295)
at org.apache.hadoop.mapred.ReduceTask.runOldReducer(ReduceTask.java:453)
at org.apache.hadoop.mapred.ReduceTask.run(ReduceTask.java:392)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1693)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Caused by: org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: Found unrecoverable error [xx.xxx.xxx.xx:9200] returned Bad Request(400) - Could not dynamically add mapping for field [geo_custom.lat]. Existing mapping for [geo_custom] must be of type object but found [geo_point].; Bailing out..
... 7 more
Error Logged in ElastcSearch Log:
[2016-11-11T17:15:02,172][DEBUG][o.e.a.b.TransportShardBulkAction] [test-es03] [xxxxx-2016.11.02][3] failed to execute bulk item (index) index {[xxxxx-2016.11.02][Yyyyy][AVhTNIpmSQciAFrftxGY], source[{"geo_custom.lat":"18.73793","geo_custom.lon":"128.922"}]}
org.elasticsearch.index.mapper.MapperParsingException: Could not dynamically add mapping for field [geo_custom.lat]. Existing mapping for [geo_custom] must be of type object but found [geo_point].
at org.elasticsearch.index.mapper.DocumentParser.getDynamicParentMapper(DocumentParser.java:843) ~[elasticsearch-5.0.0.jar:5.0.0]
at org.elasticsearch.index.mapper.DocumentParser.parseValue(DocumentParser.java:569) ~[elasticsearch-5.0.0.jar:5.0.0]
at......
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_102]
Basically this shows that, I can't ingest/map a data type of "object" into a data type of "geo_point". The point is Hive doesn't know what's a "geo_point" data type. How to solve this issue? Any suggestion / alternate ingestion method would be greatly appreciated.
Thanks