密钥太大,不能通过汇总来指示频率

时间:2016-01-31 06:15:11

标签: mongodb

我尝试使用聚合来计算具有相同normalized_link

的文档的频率

它给了我key too large to index,而且似乎normalized_link \"http://www.funpepper.com/share/game/?infos=OtnZDeyCWe5oR-ziY_-p...\"的值太长了。

然而,值\"http://www.funpepper.com/share/game/?infos=OtnZDeyCWe5oR-ziY_-p...\"是我想要计算的

我怎么能这样做?感谢

错误消息

    {
      "errmsg": "exception: insert for $out failed: { connectionId: 1, err: \"Btree::insert: key too large to index, failing alibuddha.tmp.agg_out.2.$_id_ 1208 { : \"http://www.funpepper.com/share/game/?infos=OtnZDeyCWe5oR-ziY_-p...\", code: 17280, n: 0, ok: 1.0 }",

查询语法

      pipeline = [
        {
        '$project': {
          'doc': '$$ROOT',
          'id': '$$ROOT.ID',
          'normalized_link': '$$ROOT.normalized_link'
            }
        },
        { "$group": {
            "_id": "$doc.normalized_link",
            "frequency": { "$sum": 1 }
        }},
        {
            '$project': {
              'count': '$count',
            }
          }, {
            '$out': "stats_records"
          }
    ]



    db["comments"].runCommand('aggregate', {
      pipeline: pipeline,
      allowDiskUse: true
    });

0 个答案:

没有答案