【发布时间】:2017-05-12 16:59:11
【问题描述】:
我从 PHP 运行两个 MongoDB 查询,一个针对第一个集合(名为“products”),第二个针对另一个集合(名为 stats)。
两个集合的一些数据:
{
"_id" : "20711122",
"labels_hierarchy" : [
"en:pgi"
],
"languages_hierarchy" : [
"en:french"
],
"labels_prev_hierarchy" : [
"en:pgi"
],
"languages" : {
"en:french" : 5
},
"countries_tags" : [
"en:france"
],
"purchase_places_debug_tags" : [],
"photographers_tags" : [
"tacite"
]
}
其他收藏:
{
"_id" : "7613035010550",
"purchases" : [
{
"date" : ISODate("2017-04-15T14:15:00.000Z"),
"coords" : {
"lon" : 43.729604,
"lat" : 1.416017
},
"metar" : {},
"quantity" : 1,
"price" : 2.31
},
{
"date" : ISODate("2017-05-02T16:23:00.000Z"),
"coords" : {
"lon" : 43.722862,
"lat" : 1.415837
},
"metar" : {},
"quantity" : 6,
"price" : 12
},
{
"date" : ISODate("2017-05-02T18:32:00.000Z"),
"coords" : {
"lon" : 46.307353,
"lat" : 3.28937
},
"metar" : {},
"quantity" : 2,
"price" : 5
}
],
"rates" : [
{
"value" : 5
},
{
"value" : 4
},
{
"value" : 5
},
{
"value" : 2
}
]
}
如您所见,集合不同,但“_id”键...
当我对第一个集合(产品)运行查询时,一切正常,但具有相同“_key”的第二个返回空结果,这是两个查询的跟踪(使用 MongoDB 的 executeQuery() 进行的::司机):
<pre><code>Interrogation de la collection : stats
Avec le filtre :
{"id":"7613035010550"}
<pre><code>Interrogation de la collection : products
Avec le filtre :
{"id":"7613035010550"}
Results :
{"ean":"7613035010550","title":"Eau Min\u00e9rale Naturelle","image":"https:\/\/static.openfoodfacts.org\/images\/products\/761\/303\/501\/0550\/front_fr.11.400.jpg","brands":"Vittel","categories":["Boissons","Eaux","Eaux min\u00e9rales","Eaux min\u00e9rales naturelles","Boissons non sucr\u00e9es"],"quantity":"1.5 l."}
如您所见,只有第一个查询返回结果,而不是第二个......
知道这种奇怪的行为吗?
谢谢 4 帮助,
JL
【问题讨论】: