mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-02 12:22:18 +00:00
## What changed? Adds Archetype search attributes schema for CHASM Visibility. Functions similarly to custom search attributes, where pre-allocated column names or explicit properties, called field names, will map to user aliased Archetype search attributes. Adds Archetype search attributes to ClusterMetadata to save all pre-allocated field name to type mappings in the Cassandra backed ClusterMetadata store. ## Why? Required for CHASM Visibility support. Component authors will register a component with tagged attribute values for querying (List, Count APIs for now), and executions of the registered component will be tagged with these attributes. Archetype name used for querying is left out of this schema change, may require further discussion. ## How did you test it? - [X] built - [X] run locally and tested manually - [ ] added new unit test(s) - [ ] added new functional test(s)
96 lines
2.3 KiB
Bash
Executable File
96 lines
2.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -eu -o pipefail
|
|
|
|
# Prerequisites:
|
|
# - jq
|
|
# - curl
|
|
|
|
# Input parameters.
|
|
: "${ES_SCHEME:=http}"
|
|
: "${ES_SERVER:=127.0.0.1}"
|
|
: "${ES_PORT:=9200}"
|
|
: "${ES_USER:=}"
|
|
: "${ES_PWD:=}"
|
|
: "${ES_VERSION:=v7}"
|
|
: "${ES_VIS_INDEX_V1:=temporal_visibility_v1_dev}"
|
|
: "${AUTO_CONFIRM:=}"
|
|
: "${SLICES_COUNT:=auto}"
|
|
|
|
es_endpoint="${ES_SCHEME}://${ES_SERVER}:${ES_PORT}"
|
|
|
|
echo "=== Step 0. Sanity check if Elasticsearch index is accessible ==="
|
|
|
|
if ! curl --silent --fail --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/${ES_VIS_INDEX_V1}/_stats/docs" --write-out "\n"; then
|
|
echo "Elasticsearch index ${ES_VIS_INDEX_V1} is not accessible at ${es_endpoint}."
|
|
exit 1
|
|
fi
|
|
|
|
echo "=== Step 1. Add new builtin search attributes ==="
|
|
|
|
new_mapping='
|
|
{
|
|
"properties": {
|
|
"TemporalBool01": {
|
|
"type": "boolean"
|
|
},
|
|
"TemporalBool02": {
|
|
"type": "boolean"
|
|
},
|
|
"TemporalDatetime01": {
|
|
"type": "date_nanos"
|
|
},
|
|
"TemporalDatetime02": {
|
|
"type": "date_nanos"
|
|
},
|
|
"TemporalDouble01": {
|
|
"type": "scaled_float",
|
|
"scaling_factor": 10000
|
|
},
|
|
"TemporalDouble02": {
|
|
"type": "scaled_float",
|
|
"scaling_factor": 10000
|
|
},
|
|
"TemporalInt01": {
|
|
"type": "long"
|
|
},
|
|
"TemporalInt02": {
|
|
"type": "long"
|
|
},
|
|
"TemporalKeyword01": {
|
|
"type": "keyword"
|
|
},
|
|
"TemporalKeyword02": {
|
|
"type": "keyword"
|
|
},
|
|
"TemporalKeyword03": {
|
|
"type": "keyword"
|
|
},
|
|
"TemporalKeyword04": {
|
|
"type": "keyword"
|
|
},
|
|
"TemporalKeywordList01": {
|
|
"type": "keyword"
|
|
},
|
|
"TemporalKeywordList02": {
|
|
"type": "keyword"
|
|
}
|
|
}
|
|
}
|
|
'
|
|
|
|
if [ -z "${AUTO_CONFIRM}" ]; then
|
|
read -p "Add new builtin search attributes to the index ${ES_VIS_INDEX_V1}? (N/y)" -n 1 -r
|
|
echo
|
|
else
|
|
REPLY="y"
|
|
fi
|
|
if [ "${REPLY}" = "y" ]; then
|
|
curl --silent --fail --user "${ES_USER}":"${ES_PWD}" -X PUT "${es_endpoint}/${ES_VIS_INDEX_V1}/_mapping" -H "Content-Type: application/json" --data-binary "$new_mapping" | jq
|
|
# Wait for mapping changes to go through.
|
|
until curl --silent --user "${ES_USER}":"${ES_PWD}" "${es_endpoint}/_cluster/health/${ES_VIS_INDEX_V1}" | jq --exit-status '.status=="green" | .'; do
|
|
echo "Waiting for Elasticsearch index ${ES_VIS_INDEX_V1} become green."
|
|
sleep 1
|
|
done
|
|
fi
|