forked from gsingers/search_with_machine_learning_course
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index-annotations.sh
executable file
·51 lines (42 loc) · 1.77 KB
/
index-annotations.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
usage()
{
echo "Usage: $0 [-p /path/to/bbuy/products/field/mappings] [ -b /path/to/bbuy/products/logstash/conf ] [ -l /path/to/logstash/home ] [ -g /path/to/write/logs/to ]"
exit 2
}
PRODUCTS_JSON_FILE="/workspace/search_with_machine_learning_course/week3/conf/bbuy_annotations.json"
PRODUCTS_LOGSTASH_FILE="/workspace/search_with_machine_learning_course/week3/conf/index-bbuy-http-filter.logstash"
LOGSTASH_HOME="/workspace/logstash/logstash-7.13.2"
LOGS_DIR="/workspace/logs"
while getopts ':p:q:b:e:g:l:h' c
do
case $c in
p) PRODUCTS_JSON_FILE=$OPTARG ;;
q) QUERIES_JSON_FILE=$OPTARG ;;
b) PRODUCTS_LOGSTASH_FILE=$OPTARG ;;
e) QUERIES_LOGSTASH_FILE=$OPTARG ;;
g) LOGS_DIR=$OPTARG ;;
l) LOGSTASH_HOME=$OPTARG ;;
h) usage ;;
[?]) usage ;;
esac
done
shift $((OPTIND -1))
cd data/phone_products
gunzip -k phone_products.xml.gz
cd ../../
set -x
echo "Creating index settings and mappings"
echo " Product Annotations file: $PRODUCTS_JSON_FILE"
curl -k -X PUT -u admin "https://localhost:9200/bbuy_annotations" -H 'Content-Type: application/json' -d "@$PRODUCTS_JSON_FILE"
echo ""
echo ""
echo "Writing logs to $LOGS_DIR"
mkdir -p $LOGS_DIR
echo "Indexing"
echo " Product Annotations Logstash file: $PRODUCTS_LOGSTASH_FILE"
echo "Running Logstash found in $LOGSTASH_HOME"
cd "$LOGSTASH_HOME"
echo "Launching Logstash indexing in the background via nohup. See product_annotations_indexing.log for log output"
echo " Cleaning up any old indexing information by deleting products_data. If this is the first time you are running this, you might see an error."
rm -rf "$LOGSTASH_HOME/products_annotations_data"
nohup bin/logstash --pipeline.workers 7 --path.data ./products_annotations_data -f "$PRODUCTS_LOGSTASH_FILE" > "$LOGS_DIR/product_annotations_indexing.log" &