在MongoDb.exe上我可以只使用一个字段进行查询,如下所示:
db.cache_sta.find({ip:" 10.5.8.17"},{_ id:0,hostname:1})
{"主机名" :" iPad-Blanka" }
我尝试使用mongoexport.exe
执行相同的操作mongoexport.exe /h 127.0.0.1:27117 /d ace /c cache_sta /q {ip:\"10.5.8.17\"},{"_id":0,hostname:1}
结果:
error validating settings: query '{ip:"10.5.8.17"},{_id:0,hostname:1}' is not valid JSON: invalid character ',' after top-level value
答案 0 :(得分:0)
仅显示具有特定IP字段的文档的主机名字段的解决方案是:
mongo -port 27117 -host 127.0.0.1 ace --quiet --eval "db.cache_sta.find({ip:'10.5.2.84'}, {_id:0,hostname:1}).forEach(printjson)"
输出:
{ "hostname" : "GWF090L" }