From 80bca23534362043fcf8257b0cda298b37cb5944 Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:25:07 +0100 Subject: [PATCH 1/4] Make 'pelias elastic stats' use index from pelias.json instead of static index name --- cmd/elastic.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cmd/elastic.sh b/cmd/elastic.sh index 701c19c9..8c418e4b 100644 --- a/cmd/elastic.sh +++ b/cmd/elastic.sh @@ -62,7 +62,14 @@ function elastic_info(){ curl -s "http://${ELASTIC_HOST:-localhost:9200}/"; } register 'elastic' 'info' 'display elasticsearch version and build info' elastic_info function elastic_stats(){ - curl -s "http://${ELASTIC_HOST:-localhost:9200}/pelias/_search?request_cache=true&timeout=10s&pretty=true" \ + #Extract the API section from the pelias.json + api_section=$(cat "$DATA_DIR/../pelias.json" | sed -n '/"api": {/,/}/p') + #Extract the value of api.indexName + index_name=$(echo "$api_section" | grep '"indexName"' | sed 's/.*"indexName": "\(.*\)".*/\1/') + #Add info which index is queried + echo "Results for index\" ${index_name:-"pelias"}\":" + #Query the index in question or use the default name (pelias) + curl -s "http://${ELASTIC_HOST:-localhost:9200}/${index_name:-"pelias"}/_search?request_cache=true&timeout=10s&pretty=true" \ -H 'Content-Type: application/json' \ -d '{ "aggs": { From ab801a9edc56358da6c715359e73e1e5774d24d3 Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Mon, 10 Mar 2025 09:56:50 +0100 Subject: [PATCH 2/4] Fix typo --- cmd/elastic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/elastic.sh b/cmd/elastic.sh index 8c418e4b..8a753e4b 100644 --- a/cmd/elastic.sh +++ b/cmd/elastic.sh @@ -67,7 +67,7 @@ function elastic_stats(){ #Extract the value of api.indexName index_name=$(echo "$api_section" | grep '"indexName"' | sed 's/.*"indexName": "\(.*\)".*/\1/') #Add info which index is queried - echo "Results for index\" ${index_name:-"pelias"}\":" + echo "Results for index \"${index_name:-"pelias"}\":" #Query the index in question or use the default name (pelias) curl -s "http://${ELASTIC_HOST:-localhost:9200}/${index_name:-"pelias"}/_search?request_cache=true&timeout=10s&pretty=true" \ -H 'Content-Type: application/json' \ From 2a5267e5bd11f3397816b6a5ff1eb685f7c3e2f5 Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Mon, 10 Mar 2025 15:29:45 +0100 Subject: [PATCH 3/4] Move pelias stats to schema --- cmd/elastic.sh | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/cmd/elastic.sh b/cmd/elastic.sh index 8a753e4b..82ae3fab 100644 --- a/cmd/elastic.sh +++ b/cmd/elastic.sh @@ -61,34 +61,5 @@ register 'elastic' 'wait' 'wait for elasticsearch to start up' elastic_wait function elastic_info(){ curl -s "http://${ELASTIC_HOST:-localhost:9200}/"; } register 'elastic' 'info' 'display elasticsearch version and build info' elastic_info -function elastic_stats(){ - #Extract the API section from the pelias.json - api_section=$(cat "$DATA_DIR/../pelias.json" | sed -n '/"api": {/,/}/p') - #Extract the value of api.indexName - index_name=$(echo "$api_section" | grep '"indexName"' | sed 's/.*"indexName": "\(.*\)".*/\1/') - #Add info which index is queried - echo "Results for index \"${index_name:-"pelias"}\":" - #Query the index in question or use the default name (pelias) - curl -s "http://${ELASTIC_HOST:-localhost:9200}/${index_name:-"pelias"}/_search?request_cache=true&timeout=10s&pretty=true" \ - -H 'Content-Type: application/json' \ - -d '{ - "aggs": { - "sources": { - "terms": { - "field": "source", - "size": 100 - }, - "aggs": { - "layers": { - "terms": { - "field": "layer", - "size": 100 - } - } - } - } - }, - "size": 0 - }'; -} +function elastic_stats(){ compose_run 'schema' node scripts/check_stats; } register 'elastic' 'stats' 'display a summary of doc counts per source/layer' elastic_stats From 56143da35916be13ac145c5785bfdb227868f5ee Mon Sep 17 00:00:00 2001 From: arnesetzer <25772747+arnesetzer@users.noreply.github.com> Date: Wed, 12 Mar 2025 10:44:12 +0100 Subject: [PATCH 4/4] feat: Allow to use param with `elastic stats` --- cmd/elastic.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/elastic.sh b/cmd/elastic.sh index 82ae3fab..cc386f8a 100644 --- a/cmd/elastic.sh +++ b/cmd/elastic.sh @@ -61,5 +61,5 @@ register 'elastic' 'wait' 'wait for elasticsearch to start up' elastic_wait function elastic_info(){ curl -s "http://${ELASTIC_HOST:-localhost:9200}/"; } register 'elastic' 'info' 'display elasticsearch version and build info' elastic_info -function elastic_stats(){ compose_run 'schema' node scripts/check_stats; } +function elastic_stats(){ compose_run 'schema' node scripts/check_stats "$@"; } register 'elastic' 'stats' 'display a summary of doc counts per source/layer' elastic_stats