Mongodb always says that there is no createindex method for indexing.

index = self.xiaoMiQuanCollection.createIndex ({"unique_charcter": 1, "name": "hashed"}, {"unique": True})
res = self.xiaoMiQuanCollection.find (index)

TypeError: "Collection" object is not callable. If you meant to call the "createIndex" method on a" Collection" object it is failing because no such method exists.

I am also wrong to write ensureIndex, ask for advice-sharp-sharp-sharp topic description

Sep.30,2021

What is the type of

self? Unless self inherits database, it will not fetch collection directly. Even then, the syntax should be self ["xiaoMiQuanCollection"] .createIndex (.)

first take a look at the basic operations of documentation: python/current/tutorial.html" rel=" nofollow noreferrer "> http://api.mongodb.com/python.

. If

pymongo, it is the create_index method
python/current/tutorial.html" rel=" nofollow noreferrer "> pymongo document link

Menu