-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathimport.sh
More file actions
executable file
·51 lines (42 loc) · 1.98 KB
/
import.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.98 KB
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
#!/bin/bash
# Check if password and dump path arguments were provided
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Error: Please provide both the Elasticsearch password and the dump path."
echo "Usage: $0 <password> <dump_path>"
exit 1
fi
# Check if the dump path is a directory
if [ ! -d "$2" ]; then
echo "Error: The provided dump path '$2' is not a directory."
exit 1
fi
# Import songs index
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/songs_mapping.json \
--output=https://elastic:$1@localhost:9200/songs \
--type=mapping
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/songs_data.json \
--output=https://elastic:$1@localhost:9200/songs \
--type=data
# Import corpuses index
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/corpuses_mapping.json \
--output=https://elastic:$1@localhost:9200/corpuses \
--type=mapping
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/corpuses_data.json \
--output=https://elastic:$1@localhost:9200/corpuses \
--type=data
# Import audio index
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/audio_mapping.json \
--output=https://elastic:$1@localhost:9200/audio \
--type=mapping
# we need to set a lower limit for batch operations to not overloard the elasticsearch server
docker run --rm --net=host -v "$(realpath "$2")":/tmp -e NODE_TLS_REJECT_UNAUTHORIZED=0 -ti elasticdump/elasticsearch-dump \
--input=/tmp/audio_data.json \
--output=https://elastic:$1@localhost:9200/audio \
--limit=20 \
--type=data
echo "Import complete. Check your Elasticsearch instance for the imported data."