Skip to content

Instantly share code, notes, and snippets.

@CesarCapillas
Last active January 3, 2024 15:30
Show Gist options
  • Save CesarCapillas/457f6b7cba9bfa65e36421d4f3e738de to your computer and use it in GitHub Desktop.
Save CesarCapillas/457f6b7cba9bfa65e36421d4f3e738de to your computer and use it in GitHub Desktop.
jq examples
# Alfresco users
curl -s -u user:pass http://localhost:8080/alfresco/service/api/people | jq '.people[] .userName'
curl -s -u user:pass http://localhost:8080/alfresco/service/api/people | jq '.people[] | "\(.userName),\(.firstName),\(.lastName),\(.email)"'
# Alfresco groups
curl -s -u user:pass http://localhost:8080/alfresco/service/api/groups | jq '.data[] .shortName'
curl -s -u user:pass http://localhost:8080/alfresco/service/api/groups | jq '.data[] | "\(.shortName),\(.fullName),\(.displayName)"'
# Alfresco sites
curl -s -u user:pass http://localhost:8080/alfresco/service/api/sites | jq '.[] .shortName'
curl -s -u user:pass http://localhost:8080/alfresco/service/api/sites | jq '.[] | "\(.shortName),\(.visibility),\(.title)"'
# Alfresco site memberships
curl -s -u user:pass http://localhost:8080/alfresco/service/api/sites/<shortname>/memberships" | jq '.[] | "\(.authority.userName),\(.role)"'
# Show numDocs,maxDoc and deletedDocs for each Alfresco core
$ curl -s "http://localhost:8983/solr/admin/cores?action=SUMMARY&wt=json" | jq '.Summary[].Searcher' | jq -r '"\(.searcherName),\(.numDocs),\(.maxDoc),\(.deletedDocs)"'
# Check SOLR nodes errors in alfresco and archive core
curl -s "http://localhost:8983/solr/alfresco/afts?q=DOC_TYPE:ErrorNode&wt=json" | jq '.response.docs[].DBID'
curl -s "http://localhost:8983/solr/archive/afts?q=DOC_TYPE:ErrorNode&wt=json" | jq '.response.docs[].DBID'
# Convert to CSV
curl -s https://api.discogs.com/users/cesarista/collection/folders/0/releases --user-agent "FooBarApp/3.0"| jq '.releases[].basic_information' | jq -r '"\(.id),\(.year),\(.title),\(.artists[0].name),\(.formats[0].name)"'
# Extract / simplify JSON
curl -s https://api.discogs.com/users/cesarista/collection/folders/0/releases --user-agent "FooBarApp/3.0"| jq '.releases[].basic_information' | jq '. | {id: .id, year: .year, title: .title, artist: .artists[0].name, format: .formats[0].name, label: .labels[0].name}'
# Show first 50 John Lennon releases in Discogs
curl -s https://api.discogs.com/artists/46481/releases | jq '.releases[]' | jq -r '"\(.id),\(.year),\(.title)"'
# Get collections
curl -s "http://localhost:8983/solr/admin/collections?action=LIST&wt=json" | jq '.collections'
curl -s "http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS&wt=json" | jq ".cluster.collections" | jq '.[] .configName'
# Get live nodes of SOLR cluster
curl -s "http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS&wt=json" | jq '.cluster.live_nodes'
# Get Alias
curl -s "http://localhost:8983/solr/admin/collections?action=CLUSTERSTATUS&wt=json" | jq '.cluster.aliases'
# Parsing solr status command
sudo service solr6 status | egrep -v "Found|process" | jq '.cloud.liveNodes'
# Parsing solr healthcheck command
sudo service solr6 healthcheck | jq '.numDocs'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment