我有一个具有以下结构的数据集。我会告诉你两份文件。
{
"business_id":"7vqhN9Ifq5DnaUkL3jyWGg",
"full_address":"1322 Pleasant View Rd\nMiddleton, WI 53562",
"hours":{ },
"open":true,
"categories":[
"Active Life",
"Golf Lessons",
"Golf",
"Fitness & Instruction"
],
"city":"Middleton",
"review_count":4,
"name":"Pleasant View Golf Course",
"neighborhoods":[
],
"longitude":-89.536493,
"state":"WI",
"stars":4.0,
"latitude":43.0875811,
"attributes":{
"Delivery":false,
"Good for Kids":true,
"Good For Groups":true,
"Good For":{
"dessert":false,
"latenight":false,
"lunch":false,
"dinner":false,
"brunch":false,
"breakfast":false
}
},
"type":"business"
}
这是另一份文件:
{
"business_id":"B0Vuwn6Hugc-0U5n31YBfg",
"full_address":"2550 Allen Blvd\nMiddleton, WI 53562",
"hours":{
"Monday":{
"close":"14:00",
"open":"06:00"
},
"Tuesday":{
"close":"14:00",
"open":"06:00"
},
"Friday":{
"close":"14:00",
"open":"06:00"
},
"Wednesday":{
"close":"14:00",
"open":"06:00"
},
"Thursday":{
"close":"14:00",
"open":"06:00"
},
"Sunday":{
"close":"13:00",
"open":"07:00"
},
"Saturday":{
"close":"14:00",
"open":"06:00"
}
},
"open":true,
"categories":[
"Bakeries",
"Food",
"American (Traditional)",
"Restaurants",
"Donuts"
],
"city":"Middleton",
"review_count":25,
"name":"C's Restaurant Bakery and Coffee Shop",
"neighborhoods":[
],
"longitude":-89.48674,
"state":"WI",
"stars":4.0,
"latitude":43.102896,
"attributes":{
"Take-out":true,
"Good For":{
"dessert":false,
"latenight":false,
"lunch":false,
"dinner":false,
"brunch":false,
"breakfast":true
},
"Noise Level":"average",
"Takes Reservations":false,
"Delivery":false,
"Ambience":{
"romantic":false,
"intimate":false,
"touristy":false,
"hipster":false,
"divey":false,
"classy":false,
"trendy":false,
"upscale":false,
"casual":true
},
"Parking":{
"garage":false,
"street":false,
"validated":false,
"lot":true,
"valet":false
},
"Has TV":false,
"Outdoor Seating":true,
"Attire":"casual",
"Alcohol":"none",
"Waiter Service":true,
"Accepts Credit Cards":true,
"Good for Kids":true,
"Good For Groups":true,
"Price Range":1
},
"type":"business"
}
我的收藏中有80000个文件。 "属性中的字段"每个文件都不一样。如何归还所有具有休闲氛围的文件?#34;。 这就是我试过的:
db.yelp_dataset.find({"attributes.Ambience.casual" :"true"})
但是我没有得到任何返回的数据。可能是什么问题?请帮助。
答案 0 :(得分:2)
您正在存储嵌入的文档属性.Ambience.casual字段的值为布尔值,而在查找文档时,您传递的值为字符串,这就是没有数据返回的原因。
试试这个
db.yelp_dataset.find({"attributes.Ambience.casual" :true});
而不是
db.yelp_dataset.find({"attributes.Ambience.casual" :"true"});