Search code examples
ibm-cloudcloudant

How to calculate document size in Cloudant?


I'll use Cloudant to store some documents returned from an API, how can I estimate the approximate space needed by document, here is a sample document:

{
  "document_tone": {
    "tone_categories": [
      {
        "tones": [
          {
            "score": 0.25482,
            "tone_id": "anger",
            "tone_name": "Anger"
          },
          {
            "score": 0.345816,
            "tone_id": "disgust",
            "tone_name": "Disgust"
          },
          {
            "score": 0.121116,
            "tone_id": "fear",
            "tone_name": "Fear"
          },
          {
            "score": 0.078903,
            "tone_id": "joy",
            "tone_name": "Joy"
          },
          {
            "score": 0.199345,
            "tone_id": "sadness",
            "tone_name": "Sadness"
          }
        ],
        "category_id": "emotion_tone",
        "category_name": "Emotion Tone"
      }
    ]
  }
}

Thank you


Solution

  • If you save your json in a file, you could try something like

    cat file.json | jq --compact-output '' | wc -c
    

    which says that the file above is about 398 chars. In Cloudant you also may incur index space, depending on your setup.