1
我的$ne : ""
與pymongo無法正常工作。
hashtable['ACR-WEB-01']=db.logs.find({"host_name" : "WEB-01"}, {"service_description": {"$ne" : ""}}).distinct("service_description")
print hashtable['ACR-WEB-01']
打印的結果是:
[u'Disks', u'', u'Mem', u'VM Tools', u'Cpu', u'vm-alarm-CPU', u'vm-alarm-MEM', u'vm-alarm-VMTOOLS', u'Uptime']
正如你所看到的,我得到u''
爲什麼呢?
如果我直接在MongoDB中執行此,它的工作原理:
> db.logs.distinct("service_description" , { "host_name" : "WEB-01", service_description: {$ne : ""}})
[
"Cpu",
"Disks",
"Mem",
"Uptime",
"VM Tools",
"vm-alarm-CPU",
"vm-alarm-MEM",
"vm-alarm-VMTOOLS"
]
感謝您的幫助