Skip to content

Instantly share code, notes, and snippets.

@danielsnider
Last active April 15, 2019 17:23
Show Gist options
  • Save danielsnider/0e1fb2b3aa6ee77c06207f4879aa9a99 to your computer and use it in GitHub Desktop.
Save danielsnider/0e1fb2b3aa6ee77c06207f4879aa9a99 to your computer and use it in GitHub Desktop.
Count number of not-null values for every field in ElasticSearch index
for FIELD_NAME in $(curl -s -XGET localhost:9200/image/_mapping | jq .image.mappings.image.properties | jq 'keys' | jq .[]); do NUM_NOT_NULL=$(curl -s -H 'Content-Type: application/json' -XGET 'http://127.0.0.1:9200/image/image/_search' -d '
{
"query" : {
"constant_score" : {
"filter" : {
"exists" : {
"field" : '"$FIELD_NAME"'
}
}
}
}
}
' | jq .hits.total); echo "$FIELD_NAME: $NUM_NOT_NULL"; done | tee out.json
@danielsnider
Copy link
Author

Example output:

"RFEchoTrainLength": 31081
"RRIntervalVector": 597
"RWavePointer": 1859
"RadialPosition": 346
"RadiationMode": 14055
...

This is the number of empty values per field in an ElasticSearch index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment