Last active
May 28, 2016 12:14
-
-
Save leetschau/1eca199593f7bef4441d42b71c17a678 to your computer and use it in GitHub Desktop.
MongoDB导出的json数据中,时间字段前面都有{$date: 2016.04.04},$date不能被Elasticsearch识别,需要去掉,从{"timeStart: {$date: "xxx"}}变成{"timeStart: "xxx"}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sed 's/{\"\$date\":\(\".\{10\}T.\{12\}Z\"\)}/\1/g' f1000.json > temp.json | |
sed -i 25d temp.json | |
mongoimport -d test -c strDate --type json --file temp.json | |
# sample data: | |
"timeStart":{"$date":"1015-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2018-03-02T00:00:00.000Z"}, | |
"timeStart":{"$date":"2016-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2021-04-0kT00:00:00.000Z"}, | |
"timeStart":{"$date":"2017-09-01T00:00:00.000Z"},"timeEnd":{"$date":"2021-05-09T00:00:00.000Z"}, | |
"timeStart":{"$date":"2017-09-01T00:00:00.000Z"}, | |
"timeStart":"$date":"2017-09-01T00:00:00.000Z"}, | |
"timeStart":{$date:1017-09-01T00:00:00.000Z}, | |
timeStart:{$date:2017-09-01T00:00:00.000Z}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment