On Thu, Nov 05, 2020 at 03:41:54PM +0800, Zhang Yuhang wrote:
[why] We need a script to create "repo" mapping in es.
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
sbin/es-repo-mapping.sh | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 sbin/es-repo-mapping.sh
diff --git a/sbin/es-repo-mapping.sh b/sbin/es-repo-mapping.sh new file mode 100755 index 0000000..3a3930e --- /dev/null +++ b/sbin/es-repo-mapping.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# Check if "repo" index already exists. +status_code=$(curl -sIL -w "%{http_code}\n" -o /dev/null http://localhost:9200/repo) +[ $status_code -eq 200 ] && echo '"repo" index already exists. Exit.' && exit
delete ^
Thanks, Ping
+# Create "repo" index. +echo 'Start to create "repo" index.' +curl -H 'Content-Type: Application/json' -XPUT 'http://localhost:9200/repo' -d ' +{
- "mappings": {
"_doc": {
"properties": {
"git_repo": {
"type": "keyword"
},
"pkgbuild_repo": {
"type": "keyword"
},
"url": {
"type": "keyword"
},
"fetch_time": {
"type": "keyword"
},
"new_refs_time": {
"type": "keyword"
},
"offset_fetch": {
"type": "long"
},
"offset_new_refs": {
"type": "long"
},
"priority": {
"type": "long"
},
"queued": {
"type": "boolean"
}
}
}
- }
+}'
+[ $? -ne 0 ] && echo 'Failed to create "repo" index.'
2.23.0