Skip to content

Instantly share code, notes, and snippets.

@jaytaylor
Created August 26, 2014 23:53
Show Gist options
  • Select an option

  • Save jaytaylor/cf32a3ef68c1b5727814 to your computer and use it in GitHub Desktop.

Select an option

Save jaytaylor/cf32a3ef68c1b5727814 to your computer and use it in GitHub Desktop.
Elasticsearch document sum counter for a set of indices matching a particular pattern.
#!/usr/bin/env bash
pattern=''
host='localhost:9200'
expr $(
curl --fail --silent http://${host}/_cat/indices?v | \
sed 's/ \{1,\}/ /g' | \
grep " ${pattern}.*" | \
cut -d' ' -f5 | \
tr '\n' '+' | \
sed 's/+$//' | \
sed 's/+/ + /g'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment