Hive date shows null in elasticsearch


(parthiban) #1

I have a hive table details with below schema

name STRING,
address STRING,
dob DATE

My dob is stored in yyyy-mm-dd format.like 1988-01-27.

I am trying to load this elastic search table . So i followed below instruction in HUE.

CREATE EXTERNAL TABLE sampletable (name STRING, address STRING, dob DATE)
ROW FORMAT SERDE 'org.elasticsearch.hadoop.hive.EsSerDe'
STORED BY 'org.elasticsearch.hadoop.hive.EsStorageHandler' TBLPROPERTIES('es.resource' = 'test4/test4','es.nodes' = 'x.x.x.x:9200');

INSERT OVERWRITE TABLE sampletable SELECT * FROM details;

select * from sample table;
But DOB field shows NULL for all coloumn. Whereas I can verify that my original hive table has data in date field.

After some research I was able to find that Elasticsearch expects data field to be in yyyy-mm-ddThh:mm:zz since my data doesn't match that it throws error. And also it mentioned, I can change the format to "strict_date" format, then it will work fine my hive date format. But I am not sure where in hive query i execute I need to mention this. I mean I am not sure about the property I need to give a try.

I tired like

"TBLPROPERTIES('es.resource' = 'test4/test4','es.nodes' = 'x.x.x.x:9200','es.mapping.name' = 'dob:{"type":"date","format":"strict_format"');

But it didnot work either
Can some one help me with this?


(system) #2

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.