こんにちは、私のコレクションには次のドキュメント構造が含まれています
{ "_id" : ObjectId("5242c91044aef624318eaf7d"), "memoryUtilization" : "10", "cpuUtilization" : "4", "hostId" : "10.9.1.3", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf7e"), "memoryUtilization" : "31", "cpuUtilization" : "0", "hostId" : "10.9.1.14", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf7f"), "memoryUtilization" : "61", "cpuUtilization" : "12", "hostId" : "10.9.10.40", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf80"), "memoryUtilization" : "61", "cpuUtilization" : "12", "hostId" : "10.9.17.41", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf81"), "memoryUtilization" : "55", "cpuUtilization" : "10", "hostId" : "10.9.1.42", "timestamp" : 1379570550000, "device_type" : "snmp" }
ここで、hostId が「10.9.1」で始まるすべてのドキュメントが必要なため、結果は次のようになります。
{ "_id" : ObjectId("5242c91044aef624318eaf7d"), "memoryUtilization" : "10", "cpuUtilization" : "4", "hostId" : "10.9.1.3", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf7e"), "memoryUtilization" : "31", "cpuUtilization" : "0", "hostId" : "10.9.1.14", "timestamp" : 1379570550000, "device_type" : "snmp" }
{ "_id" : ObjectId("5242c91044aef624318eaf81"), "memoryUtilization" : "55", "cpuUtilization" : "10", "hostId" : "10.9.1.42", "timestamp" : 1379570550000, "device_type" : "snmp" }
そのために、次のクエリを書きましたが、機能しません
db.collectionsname.find({"hostId":/10.9.1./})
10.9.1.42、10.9.10.40 などの hostId を含むすべての結果が表示されます。