Last active
April 15, 2019 17:23
-
-
Save danielsnider/0e1fb2b3aa6ee77c06207f4879aa9a99 to your computer and use it in GitHub Desktop.
Count number of not-null values for every field in ElasticSearch index
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example output:
This is the number of empty values per field in an ElasticSearch index.