[SERVER-28647] group() can't handle more than 20000 unique keys Created: 06/Apr/17  Updated: 31/May/17  Resolved: 06/Apr/17

Status: Closed
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Question Priority: Major - P3
Reporter: shenjiawei Assignee: Kelsey Schubert
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

linux


Attachments: File bug.py    
Issue Links:
Duplicate
duplicates SERVER-12305 Allow command request and response BS... Backlog
Participants:

 Description   

reducer = Code("""function(obj, prev){prev.count++;}""")
keys = {'event':True,'type':True}
conditions = {'event':'video_start'} 
a = posts.group(key=keys,condition=conditions, initial={"count": 0}, reduce=reducer)
for i in a:
    print i['type']
    keys = {'sn':True,'clip':True,'type':True}
    conditions = {'event':'video_play_blockend','type':i['type']}
    a = posts.group(key=keys,condition=conditions, initial={"count": 0}, reduce=reducer)
    for t in a:
        if t['count']>=3:
            print t
    print 1-round(len(a)/i['count'],2),i['type']
    print len(a),i['count'],i['type']

Traceback (most recent call last):
File "read.py", line 24, in <module>
a = posts.group(key=keys,condition=conditions, initial={"count": 0}, reduce=reducer)
File "/usr/lib64/python2.6/site-packages/pymongo/collection.py", line 1941, in group
collation=collation)["retval"]
File "/usr/lib64/python2.6/site-packages/pymongo/collection.py", line 232, in _command
collation=collation)
File "/usr/lib64/python2.6/site-packages/pymongo/pool.py", line 419, in command
collation=collation)
File "/usr/lib64/python2.6/site-packages/pymongo/network.py", line 116, in command
parse_write_concern_error=parse_write_concern_error)
File "/usr/lib64/python2.6/site-packages/pymongo/helpers.py", line 210, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: errmsg: "group() can't handle more than 20000 unique keys"



 Comments   
Comment by shenjiawei [ 10/Apr/17 ]

thank you for your help.

Comment by Kelsey Schubert [ 06/Apr/17 ]

Hi shenjiawei,

Thanks for the report. As Bernie mentioned, this is the expected behavior and is a known limitation of the aggregation framework. I'm marking this ticket as a duplicate of SERVER-12305, which would allow the results of the aggregation framework to exceed 16MB, and consequently enable us to modify this limit. Please feel free to vote for SERVER-12305 and watch it for updates.

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question about workarounds to this limitation involves more discussion and would be best posted on the mongodb-users group.

Kind regards,
Thomas

Comment by Bernie Hackett [ 06/Apr/17 ]

This is a limitation of the group command in the server:

https://docs.mongodb.com/manual/reference/method/db.collection.group/#limits-and-restrictions

Comment by shenjiawei [ 06/Apr/17 ]

I want konw how to solve my requirement

Generated at Thu Feb 08 04:18:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.