Reputation: 313
I am using below code to create a partial index in mongodb for the records having null values. When I execute the below code.
db = self.db_conn[db_name ]
collection = db[collection_name]
status = collection.create_index([("Col1", pym.ASCENDING), ("Col2", pym.ASCENDING)], {partialFilterExpression : {"value": None}})
Its giving me a error:
"name 'partialFilterExpression' is not defined"
My pymongo version 3.2.2 Mongodb version 3.4
Upvotes: 3
Views: 1970
Reputation: 313
Never mind Thanks for look into my post. I found it
status = collection.create_index([("Col1", pym.ASCENDING), ("col2", pym.ASCENDING)], partialFilterExpression = {"Values": None}, background = True)
It should be "=" instead of ":"
Upvotes: 6