-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeilisearch__index_reset.sh
executable file
·64 lines (57 loc) · 1.49 KB
/
meilisearch__index_reset.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
#!/bin/bash
# DS_MEILI_MASTERKEY= MEILI_SERVER= INDEX= ./meilisearch__reset-index.sh
if [[ -z "$DS_MEILI_MASTERKEY" ]]; then
echo 'DS_MEILI_MASTERKEY missing'
exit
fi
if [[ -z "$DS_MEILI_SERVER" ]]; then
echo 'MEILI_SERVER missing'
exit
fi
if [[ -z "$DS_MEILI_INDEX" ]]; then
echo 'INDEX missing'
exit
fi
# Delete
echo "DELETE? Meili server and index: $DS_MEILI_SERVER and $DS_MEILI_INDEX"
read -p "Continue? (y/n)" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo
exit
fi
curl --silent --insecure \
-X DELETE "$DS_MEILI_SERVER/indexes/$DS_MEILI_INDEX" \
-H "Authorization: Bearer $DS_MEILI_MASTERKEY" \
| jq .
# Create
echo "CREATE? Meili server and index: $DS_MEILI_SERVER and $DS_MEILI_INDEX"
read -p "Continue? (y/n)" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo
exit
fi
curl --silent --insecure \
-X POST "$DS_MEILI_SERVER/indexes" \
-H "Authorization: Bearer $DS_MEILI_MASTERKEY" \
-H 'Content-Type: application/json' \
--data-binary "{
\"uid\": \"$DS_MEILI_INDEX\",
\"primaryKey\": \"id\"
}" \
| jq .
# Settings
echo "SETTINGS? Meili server and index: $DS_MEILI_SERVER and $DS_MEILI_INDEX"
read -p "Continue? (y/n)" -n 1 -r
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo
exit
fi
curl --silent --insecure \
-X PATCH "$DS_MEILI_SERVER/indexes/$DS_MEILI_INDEX/settings" \
-H "Authorization: Bearer $DS_MEILI_MASTERKEY" \
-H 'Content-Type: application/json' \
--data @/home/lex/mwstakeorgdevclone/extensions/Dataspects/src/indexsettings.json \
| jq .