如何计算 Cloudant 中的文档大小?

How to calculate document size in Cloudant?

我将使用 Cloudant 存储从 API 返回的一些文档,我如何估计文档所需的 近似值 space,这里是示例文档:

{
  "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"
      }
    ]
  }
}

谢谢

如果您将 json 保存在文件中,您可以尝试

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

表示上面的文件大约有 398 个字符。在 Cloudant 中,您还可能产生索引 space,具体取决于您的设置。

此外,您可以对 https://$USERNAME.cloudant.com/$DATABASE 发出 GET 请求,它将 return 数据库的详细信息供您准确估计。可以在此处找到更多信息:https://docs.cloudant.com/database.html#read