On the Use of $slice in mongodb’s aggregate ()

  mongodb, question

In mongodb, use aggregate (function as aggregate), pipe is written as follows:

pipe = [

The address field is of the list type, and then you want to take out the first item in the address and add one when there is one, but you always report an error:

OperationFailure: command SON([(‘aggregate’, u’item_info_3′), (‘pipeline’, [{‘$match’: {‘time’: ‘03.02’}}, {‘$group’: {‘counts’: {‘$sum’: 1}, ‘_id’: {‘$slice’: [‘$address’, 0, 1]}}}, {‘$sort’: {‘counts’: -1}}]), (‘cursor’, {})]) on namespace GanjiData.$cmd failed: exception: invalid operator ‘$slice’

I don’t know why, please take a look at the experts, thank you very much!

I don’t know about youmongodbWhat is the version of, according tomongodb docsAs shown above,aggregationThe$sliceonmongodb 3.2I joined it later.