Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmd/elastic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pelias.json file is not always relative to the $DATA_DIR.

#Extract the value of api.indexName
index_name=$(echo "$api_section" | grep '"indexName"' | sed 's/.*"indexName": "\(.*\)".*/\1/')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to avoid using sed if possible, jq would be good option if it didn't introduce an external dependency. maybe node -e is the best option for this and the above?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works, but only when the node_modules directory is present, which it isn't for the docker bash scripts 😿

node -e "console.log(require('pelias-config').generate().schema.indexName)"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's best to move this into the pelias/schema module and then call it through docker?

Copy link
Copy Markdown
Contributor Author

@arnesetzer arnesetzer Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, should resolve all the current problems.

#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": {
Expand Down