Last active
April 9, 2024 22:56
-
-
Save glennga/9c68a9db2fe24836bb409a7e68b28a3a to your computer and use it in GitHub Desktop.
Yelp Data Loader (Couchbase)
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
#!/usr/bin/env bash | |
COUCHBASE_INSTALL_DIR=/.../source/install/bin | |
if [[ -z "$YELP_BUSINESSES_PATH" ]]; then | |
echo "Environment variable YELP_BUSINESSES_PATH is not set!" | |
exit 1 | |
elif [[ -z "$YELP_REVIEWS_PATH" ]]; then | |
echo "Environment variable YELP_REVIEWS_PATH is not set!" | |
exit 1 | |
elif [[ -z "$YELP_CHECKINS_PATH" ]]; then | |
echo "Environment variable YELP_CHECKINS_PATH is not set!" | |
exit 1 | |
fi | |
$COUCHBASE_INSTALL_DIR/couchbase-cli bucket-delete \ | |
--cluster http://localhost:8091 \ | |
--username admin \ | |
--password password \ | |
--bucket yelp | |
sleep 1 | |
$COUCHBASE_INSTALL_DIR/couchbase-cli bucket-create \ | |
--cluster http://localhost:8091 \ | |
--username admin \ | |
--password password \ | |
--bucket yelp \ | |
--bucket-type couchbase \ | |
--bucket-ramsize 1024 \ | |
--bucket-eviction-policy "fullEviction" | |
sleep 1 | |
$COUCHBASE_INSTALL_DIR/cbq \ | |
--engine http://localhost:8093 \ | |
--user admin \ | |
--password password \ | |
--script "CREATE COLLECTION yelp._default.businesses;" \ | |
--script "CREATE COLLECTION yelp._default.reviews;" \ | |
--script "CREATE COLLECTION yelp._default.checkins;" | |
echo "Importing 'yelp._default.businesses'." | |
$COUCHBASE_INSTALL_DIR/cbimport json \ | |
--cluster http://localhost:8091 \ | |
--username admin \ | |
--password password \ | |
--bucket yelp \ | |
--dataset "$YELP_BUSINESSES_PATH" \ | |
--format lines \ | |
--generate-key "key::#UUID#" \ | |
--scope-collection-exp "_default.businesses" | |
sleep 1 | |
echo "Importing 'yelp._default.reviews'." | |
$COUCHBASE_INSTALL_DIR/cbimport json \ | |
--cluster http://localhost:8091 \ | |
--username admin \ | |
--password password \ | |
--bucket yelp \ | |
--dataset "$YELP_REVIEWS_PATH" \ | |
--format lines \ | |
--generate-key "key::#UUID#" \ | |
--scope-collection-exp "_default.reviews" | |
sleep 1 | |
echo "Importing 'yelp._default.checkins'." | |
$COUCHBASE_INSTALL_DIR/cbimport json \ | |
--cluster http://localhost:8091 \ | |
--username admin \ | |
--password password \ | |
--bucket yelp \ | |
--dataset "$YELP_CHECKINS_PATH" \ | |
--format lines \ | |
--generate-key "key::#UUID#" \ | |
--scope-collection-exp "_default.checkins" | |
sleep 1 | |
echo "Establishing link for Analytics Service." | |
$COUCHBASE_INSTALL_DIR/cbq \ | |
--engine http://localhost:8095 \ | |
--user admin \ | |
--password password \ | |
--script "DROP ANALYTICS SCOPE yelp IF EXISTS;" \ | |
--script "CREATE ANALYTICS SCOPE yelp;" \ | |
--script "CREATE ANALYTICS COLLECTION yelp.businesses ON yelp._default.businesses;" \ | |
--script "CREATE ANALYTICS COLLECTION yelp.reviews ON yelp._default.reviews;" \ | |
--script "CREATE ANALYTICS COLLECTION yelp.checkins ON yelp._default.checkins;" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment