create database hive_to_mongodb;
add jar /hgx/mongo-hadoop-core-1.5.1.jar /hgx/mongo-hadoop-hive-1.5.1.jar /hgx/mongo-java-driver-3.2.1.jar;
add jar /jar_tools/mongodb/mongo-hadoop-core-1.5.1.jar /jar_tools/mongodb/mongo-hadoop-hive-1.5.1.jar /jar_tools/mongodb/mongo-java-driver-3.2.1.jar;
CREATE EXTERNAL TABLE rec_o2o_app
(
id string,
uid string,
message string,
time timestamp,
inTime string,
outTime string
)
STORED BY 'com.mongodb.hadoop.hive.MongoStorageHandler'
WITH SERDEPROPERTIES('mongo.columns.mapping'='{"id":"_id","uid":"uid","message":"message","time":"time","inTime":"inTime","outTime":"outTime"}')
TBLPROPERTIES('mongo.uri'='mongodb://10.10.10.33:27017/log.REC_O2O-app');