我在查询名为Geolytix Supermarkets January 2015 update的数据集时遇到问题 问题是我运行的查询要么返回所有结果,要么根本没有结果。这是数据集的快照:
{"type":"FeatureCollection","features":
[{"type":"Feature","properties":{"OBJECTID":10001,"GLUID":1010010014,"Retailer":"The Co-operative Group",
"Fascia":"The Co-operative Food","StoreName":"New Road","Add1":"650 Oldham Road",
"Add2":"Failsworth", "Town":"Manchester","Locality":"Failsworth","Postcode":"M359DU",
"LongWGS84":-2.14949,"LatWGS84":53.515,"EastingBNG":390185,"NorthingBNG":402050,"PQIflag":2},"geometry":
{"type":"Point","coordinates":[-2.1494900003123174,53.51499999980253]}},
{"type":"Feature","properties":{"OBJECTID":10002,"GLUID":1010010015,"Retailer":"The Co-operative Group",
"Fascia":"The Co-operative Food","StoreName":"Mobberley","Add1":"85 Town Lane",
"Add2":null,"Town":"Mobberley","Locality":null,"Postcode":"WA167HH","LongWGS84":-2.32905,"LatWGS84":53.3136,
"EastingBNG":378175,"NorthingBNG":379680,"PQIflag":2},"geometry":
{"type":"Point","coordinates":[-2.329049999711877,53.31359999998222]}},
据我所知,这个数据结构是数组中的嵌入/嵌套文档,以便检索我必须访问数组和文档的数据。为此,我使用点表示法尝试了这些查询:
db.January_2015.find ({"features.properties.Retailer":"The Co-operative Group"});
这个很清楚地返回整个数据集,这是不正确的。然后我尝试了这些:
db.January_2015.find ({"features.properties: {"OBJECTID":10001}});
db.January_2015.find ({"features.properties: {"Retailer":"The Co-operative Group}});
db.January_2015.find ({"features.properties": {$elemMatch: {"OBJECTID":10001, "GLUID": 1010010014}}});
这三个人根本没有任何回报。我已经研究了文档,根据它,至少有一种方法应该有效。我在这做错了什么? 我考虑过使用聚合框架,但对于像这样的简单查询来说,这似乎过于复杂。有人可以确认我是否尝试过正确的方法,或者我是否必须使用聚合?