数据统计
知识库数据量统计
🌱 知识库索引数量查询
- 打开 MongoDB 的
dataset_datas表 - 每个文档的
indexes字段数组长度就是该数据的索引数量 - 用这个命令快速统计👇
db.getCollection('dataset_datas').aggregate([
{ $project: { count: { $size: "$indexes" } } },
{ $group: { _id: null, total: { $sum: "$count" } } }
]);
🌱 知识库总数据量查询
# 直接对 `dataset_datas` 表里的 `q` 和 `a` 字段来波聚合操作:
db.getCollection('dataset_datas').aggregate([
{
$project: {
qLength: { $strLenCP: "$q" },
aLength: { $strLenCP: "$a" }
}
},
{
$group: {
_id: null,
totalLength: { $sum: { $add: ["$qLength", "$aLength"] } }
}
}
])
# 连自定义索引内容一起算长度
db.getCollection('dataset_datas').aggregate([
{
$unwind: "$indexes" // 先展开索引数组
},
{
$project: {
qLen: { $strLenCP: "$q" },
aLen: { $strLenCP: "$a" },
indexLen: { $strLenCP: "$indexes.text" }
}
},
{
$group: {
_id: null,
total: { $sum: { $add: ["$qLen", "$aLen", "$indexLen"] } }
}
}
])
会话次数统计
db.chats.countDocuments({})
db.chatitems.countDocuments({})
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以邮件至 ethan89@aliyun.com