我需要帮助才能解决我的问题,我想过滤掉我产品中的匹配项。
我的JSON转储
{
"_id" : ObjectId("568ff9d4d857b6850692e589"),
"UUID" : "b80b780d-be21-40f9-aee6-b321b663cb76",
"CNETID" : "S12785103",
"Url" : "intel-xeon-e5-2620v2-2-1-ghz-processor-6-kerner-15-mb-cache",
"LastChanged" : "2016-01-22 09:04:34",
"Manufacturer" : {
"UUID" : "d6e0233f-2ba1-11e5-a2ac-0050569068de",
"Title" : "Lenovo",
"Url" : "lenovo",
"SKU" : "00FE669",
"EAN" : "0883436496476"
},
"Store" : {
"Title" : "Intel Xeon E5-2620V2 - 2.1 GHz Processor - 6 kerner - 15 mb cache",
"Description" : "",
"Price" : "572200",
"PriceDiscount" : "0",
"AllowDisplay" : "1",
"Activated" : "1",
"LastSynced" : "2016-01-21 17:22:48"
},
"Category" : [
"b085ebc3-0f0f-48c8-817f-fae04093d092"
],
"PhotoCDN" : [],
"Specifications" : {
"Small" : [
{
"Header" : "Produktbeskrivelse",
"Body" : "Intel Xeon E5-2620V2 / 2.1 GHz Processor"
},
{
"Header" : "Produkttype",
"Body" : "Processor"
},
{
"Header" : "Processortype",
"Body" : "Intel Xeon E5-2620V2"
},
{
"Header" : "Antal kerner",
"Body" : "6 kerner"
},
{
"Header" : "Cache",
"Body" : "15 MB"
},
{
"Header" : "Antal processorer",
"Body" : "1"
},
{
"Header" : "Clock-frekvens",
"Body" : "2.1 GHz"
},
{
"Header" : "Max Turbo Speed",
"Body" : "2.6 GHz"
},
{
"Header" : "Bushastighed",
"Body" : "1600 MHz"
},
{
"Header" : "Producentgaranti",
"Body" : "1-års garanti"
},
{
"Header" : "Designet for",
"Body" : "System x3550 M4"
}
],
"Full" : [
{
"Header" : "Produkttype",
"Body" : "Processor"
},
{
"Header" : "Type / Model",
"Body" : "Intel Xeon E5-2620V2"
},
{
"Header" : "Antal kerner",
"Body" : "6 kerner"
},
{
"Header" : "Cache",
"Body" : "15 MB"
},
{
"Header" : "Detaljer for cache-hukommelse",
"Body" : "- 15 MB"
},
{
"Header" : "Antal processorer",
"Body" : "1"
},
{
"Header" : "Clock-frekvens",
"Body" : "2.1 GHz"
},
{
"Header" : "Max Turbo Speed",
"Body" : "2.6 GHz"
},
{
"Header" : "Bushastighed",
"Body" : "1600 MHz"
},
{
"Header" : "Termisk designstrøm",
"Body" : "80 W"
},
{
"Header" : "Installeret størrelse",
"Body" : "15 MB"
},
{
"Header" : "Service & Support",
"Body" : "1-års garanti"
},
{
"Header" : "Detaljer om service & support",
"Body" : "Begrænset garanti - 1 år"
},
{
"Header" : "Designet for",
"Body" : "Lenovo System x3550 M4"
}
],
"Search" : {
"T0000002" : "Processor",
"T0000162" : "Intel Xeon E5-2620V2",
"T0003956" : "6 kerner",
"T0001106" : "15 MB",
"T0003943" : "- 15 MB",
"T0000163" : "1",
"T0000164" : "2.1 GHz",
"T0003412" : "2.6 GHz",
"T0000366" : "1600 MHz",
"T0005726" : "80 W",
"T0000110" : "15 MB",
"T0000025" : "1-års garanti",
"T0000026" : "Begrænset garanti - 1 år",
"T0003807" : "Lenovo System x3550 M4"
}
}
}
我想要的是在我的json树中找到一个关键字
Specifications -> Full -> Array[Body]
之后,如果可能的话,我需要在这个场上编制索引。
答案 0 :(得分:1)
如何使用数组搜索文档有一个非常好的描述:
https://docs.mongodb.org/v3.0/tutorial/query-documents/#arrays
e.g。使用Prodkuttype = Processor:
查找所有文档db.cat.find({
"Specifications.Full":{
$elemMatch:{
Header: "Produkttype", Body: "Processor"
}}})