-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathimport.sh
executable file
·94 lines (81 loc) · 3.51 KB
/
import.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
BASE="/tmp/demo/bin/"
ARANGOIMP="${BASE}arangoimp"
ARANGOSH="${BASE}arangosh"
while [ 0 -lt "$#" ]; do
case "$1" in
"--arangoimp")
ARANGOIMP="$2"
shift
;;
"--arangosh")
ARANGOSH="$2"
shift
;;
*)
echo "$0: unknown option '$1'"
exit 1
;;
esac
shift
done
echo "Importing 10000 fake users into 'users'"
echo "======================================="
(echo 'db._drop("users");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file RandomUsers/names_10000.json --collection=users --create-collection=true --type=json || exit 1
(echo 'db.users.ensureHashIndex("name.first"); db.users.ensureHashIndex("name.last");' | $ARANGOSH -s) || exit 1
(echo 'db.users.ensureHashIndex("contact.address.city"); db.users.ensureHashIndex("contact.address.zip");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing cities into 'cities'"
echo "=============================="
(echo 'db._drop("cities");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file Cities/GeoLiteCity.csv --collection=cities --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureGeoIndex("latitude", "longitude");' | $ARANGOSH -s) || exit 1
(echo 'db.users.ensureHashIndex("city");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing countries into 'countries'"
echo "===================================="
(echo 'db._drop("countries");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file Countries/countries.csv --collection=countries --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureHashIndex("name");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing regions into 'regions'"
echo "================================"
(echo 'db._drop("regions");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file Regions/regions.csv --collection=regions --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureHashIndex("name");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing McDonalds France into 'mcdonalds'"
echo "==========================================="
(echo 'db._drop("mcdonalds");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file McDonalds/france.csv --collection=mcdonalds --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureGeoIndex("lat", "long");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing German Counties into 'bezirke'"
echo "========================================"
(echo 'db._drop("bezirke");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file Bezirke/bezirke.csv --collection=bezirke --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureGeoIndex("lat", "long");' | $ARANGOSH -s) || exit 1
(echo 'db.users.ensureHashIndex("FULL_NAME_RO");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing Airports into 'airports'"
echo "=================================="
(echo 'db._drop("airports");' | $ARANGOSH -s) || exit 1
$ARANGOIMP --server.password "" --file Airports/airports.csv --collection=airports --create-collection=true --type=csv || exit 1
(echo 'db.users.ensureGeoIndex("latitude_deg", "longitude_deg");' | $ARANGOSH -s) || exit 1
(echo 'db.users.ensureHashIndex("name");' | $ARANGOSH -s) || exit 1
echo
echo
echo "Importing NerdPursuit into 'nerds'"
echo "=================================="
(echo 'db._drop("nerds");' | $ARANGOSH -s) || exit 1
(cd NerdPursuit && ./nerd_pursuit_compress.sh)
(cd NerdPursuit && $ARANGOIMP --server.password "" --file nerd_pursuit_compressed.json --collection=nerds --create-collection=true --type=json) || exit 1
echo
echo