mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
## What changed? Update Visibility Schema with new TemporalLowCardinalityKeyword01 column. ## Why? Allocate additional column/ES mapping for CHASM Low Cardinality Keyword search attribute, meant for CHASM Archetype execution status. TemporalLowCardinalityKeyword fields are stored no differently than Keyword fields, but have a user requirement that values are from a low cardinal set, eg. Enums, since they support GROUP BY filtering. Normal Keyword fields do not support GROUP BY query filters. Each archetype can track its own execution status as any CHASM Low Cardinality Keyword field. ## How did you test it? - [X] built - [X] run locally and tested manually - [X] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s)
55 lines
1.5 KiB
Bash
Executable File
55 lines
1.5 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 TemporalLowCardinalityKeyword01 search attribute ==="
|
|
|
|
new_mapping='
|
|
{
|
|
"properties": {
|
|
"TemporalLowCardinalityKeyword01": {
|
|
"type": "keyword"
|
|
}
|
|
}
|
|
}
|
|
'
|
|
|
|
if [ -z "${AUTO_CONFIRM}" ]; then
|
|
read -p "Add TemporalLowCardinalityKeyword01 search attribute 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
|