2016-11-09 30 views
0

这是JSON数据如何使用查询

{ 
    "_id" : ObjectId("58107ee67a6e3f0504a2a14c"), 
    "_class" : "com.careheors.services.model.main.TangoRewards", 
    "brands" : [ 
     { 
      "description" : "Tango Card", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tango-card-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Tango Card E-Custom", 
        "sku" : "TNGO-E-V-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : true, 
        "min_price" : "1", 
        "max_price" : "500000" 
       } 
      ] 
     }, 
     { 
      "description" : "Amazon.co.jp", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/amazon-jp-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Amazon.co.jp Gift Certificate JPY 500", 
        "sku" : "AMJP-E-50000-STD", 
        "currency_code" : "JPY", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "JP" 
        ], 
        "is_variable" : false, 
        "denomination" : "50000" 
       }, 
       { 
        "description" : "Amazon.co.jp Gift Certificate JPY 1000", 
        "sku" : "AMJP-E-100000-STD", 
        "currency_code" : "JPY", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "JP" 
        ], 
        "is_variable" : false, 
        "denomination" : "100000" 
       }, 
       { 
      "description" : "Prepaid Virtual MasterCard GBP", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-mc-gbp-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual MasterCard Reward GBP", 
        "sku" : "PVMGBP-E-V-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "75000" 
       } 
      ] 
     }, 
     { 
      "description" : "Prepaid Virtual MasterCard GBP OneClick $3 Diff", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-mastercard-gbp-oneclick-3diff-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual MasterCard Reward GBP OneClick $3 Diff", 
        "sku" : "PVMGBPOC-E-V-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "75000" 
       } 
      ] 
     }, 
     { 
      "description" : "Prepaid Virtual MasterCard HKD OneClick $3 Diff", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-mastercard-hkd-oneclick-3diff-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual MasterCard Reward HKD OneClick $3 Diff", 
        "sku" : "PVMHKDOC-E-V-STD", 
        "currency_code" : "HKD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "HK" 
        ], 
        "is_variable" : true, 
        "min_price" : "6000", 
        "max_price" : "1000000" 
       } 
      ] 
     }, 
     { 
      "description" : "Prepaid Virtual MasterCard JPY OneClick $3 Diff", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-mastercard-jpy-oneclick-3diff-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual MasterCard Reward JPY OneClick $3 Diff", 
        "sku" : "PVMJPYOC-E-V-STD", 
        "currency_code" : "JPY", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "JP" 
        ], 
        "is_variable" : true, 
        "min_price" : "600", 
        "max_price" : "100000" 
       } 
      ] 
     }, 
     { 
      "description" : "Prepaid Virtual MasterCard ZAR OneClick $3 Diff", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-mastercard-zar-oneclick-3diff-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual MasterCard Reward ZAR OneClick $3 Diff", 
        "sku" : "PVMZAROC-E-V-STD", 
        "currency_code" : "ZAR", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "ZA" 
        ], 
        "is_variable" : true, 
        "min_price" : "6000", 
        "max_price" : "1000000" 
       } 
      ] 
     }, 
     { 
      "description" : "Prepaid Virtual Visa CAD", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/prepaid-virtual-visa-cad-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Prepaid Virtual Visa Reward CAD", 
        "sku" : "PVVCAD-E-V-STD", 
        "currency_code" : "CAD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "CA" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "75000" 
       } 
      ] 
     }, 
     { 
        "description" : "The Great British Pub E-Gift Code GBP 25", 
        "sku" : "TGBP-E-2500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "The Great British Pub E-Gift Code GBP 50", 
        "sku" : "TGBP-E-5000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "The Great British Pub E-Gift Code GBP 100", 
        "sku" : "TGBP-E-10000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 
     { 
      "description" : "The Home Depot*", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/home-depot-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "The Home Depot eGift Card", 
        "sku" : "HMDP1-E-V-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "200000" 
       } 
      ] 
     }, 
     { 
      "description" : "The Restaurant Card", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/restaurantcard-uk-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "The Restaurant Card UK GBP 5", 
        "sku" : "TRCUK-E-500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "500" 
       }, 
       { 
        "description" : "The Restaurant Card UK GBP 10", 
        "sku" : "TRCUK-E-1000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "The Restaurant Card UK GBP 15", 
        "sku" : "TRCUK-E-1500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "1500" 
       }, 
       { 
      "description" : "The Sports Authority*", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/sports-authority-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "Sports Authority eGift Card $5", 
        "sku" : "SPRT-E-500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "500" 
       }, 
       { 
        "description" : "Sports Authority eGift Card $10", 
        "sku" : "SPRT-E-1000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "Sports Authority eGift Card $25", 
        "sku" : "SPRT-E-2500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Sports Authority eGift Card $50", 
        "sku" : "SPRT-E-5000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "Sports Authority eGift Card $100", 
        "sku" : "SPRT-E-10000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 
     { 
      "description" : "Ticketmaster UK", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/ticketmaster-uk-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 5", 
        "sku" : "TKUK-E-500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "500" 
       }, 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 10", 
        "sku" : "TKUK-E-1000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 20", 
        "sku" : "TKUK-E-2000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "2000" 
       }, 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 25", 
        "sku" : "TKUK-E-2500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 50", 
        "sku" : "TKUK-E-5000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "Ticketmaster UK eGift Card GBP 100", 
        "sku" : "TKUK-E-10000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 
     { 
      "description" : "TJX*", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tjx-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "TJX eGift Card Custom", 
        "sku" : "TJX1-E-V-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "50000" 
       } 
      ] 
     }, 
     { 
      "description" : "TK Maxx", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tk-maxx-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "TK Maxx Gift Certificate GBP 10", 
        "sku" : "TKMX-E-1000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "TK Maxx Gift Certificate GBP 25", 
        "sku" : "TKMX-E-2500-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "TK Maxx Gift Certificate GBP 50", 
        "sku" : "TKMX-E-5000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "TK Maxx Gift Certificate GBP 100", 
        "sku" : "TKMX-E-10000-STD", 
        "currency_code" : "GBP", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "GB" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 
     { 
      "description" : "Tony Roma's", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/tony-romas-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Tony Roma's eGift Card", 
        "sku" : "TNYR-E-V-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : true, 
        "min_price" : "500", 
        "max_price" : "200000" 
       } 
      ] 
     }, 
     { 
      "description" : "Toys R US*", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/toysrus-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "Toys\"R\"Us eGift Card $5", 
        "sku" : "TOYS1-E-500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "500" 
       }, 
       { 
        "description" : "Toys\"R\"Us eGift Card $10", 
        "sku" : "TOYS1-E-1000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "Toys\"R\"Us eGift Card $25", 
        "sku" : "TOYS1-E-2500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Toys\"R\"Us eGift Card $50", 
        "sku" : "TOYS1-E-5000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "Toys\"R\"Us eGift Card $100", 
        "sku" : "TOYS1-E-10000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 

     { 
      "description" : "Whole Foods Market*", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/whole-foods-market-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "Whole Foods Market eGift $10", 
        "sku" : "WFOODS-E-1000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "1000" 
       }, 
       { 
        "description" : "Whole Foods Market eGift $25", 
        "sku" : "WFOODS-E-2500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Whole Foods Market eGift $50", 
        "sku" : "WFOODS-E-5000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "Whole Foods Market eGift $100", 
        "sku" : "WFOODS-E-10000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 

     { 
      "description" : "Xbox Live", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/xbox-gift-card-1.png", 
      "rewards" : [ 
       { 
        "description" : "Xbox Digital Gift Card $15", 
        "sku" : "XBOX1-E-1500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "1500" 
       }, 
       { 
        "description" : "Xbox Digital Gift Card $25", 
        "sku" : "XBOX1-E-2500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Xbox Digital Gift Card $50", 
        "sku" : "XBOX1-E-5000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       } 
      ] 
     }, 

     { 
      "description" : "Zappos", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/zappos-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Zappos E-Gift Card $15", 
        "sku" : "ZAPO-E-1500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "1500" 
       }, 
       { 
        "description" : "Zappos E-Gift Card $25", 
        "sku" : "ZAPO-E-2500-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "2500" 
       }, 
       { 
        "description" : "Zappos E-Gift Card $50", 
        "sku" : "ZAPO-E-5000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "5000" 
       }, 
       { 
        "description" : "Zappos E-Gift Card $100", 
        "sku" : "ZAPO-E-10000-STD", 
        "currency_code" : "USD", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "US" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     }, 
     { 
      "description" : "Zattini", 
      "image_url" : "https://dwwvg90koz96l.cloudfront.net/graphics/item-images/zattini-brl-gift-card.png", 
      "rewards" : [ 
       { 
        "description" : "Zattini Virtual Gift Card BRL 30", 
        "sku" : "ZTNI-E-3000-STD", 
        "currency_code" : "BRL", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "BR" 
        ], 
        "is_variable" : false, 
        "denomination" : "3000" 
       }, 
       { 
        "description" : "Zattini Virtual Gift Card BRL 100", 
        "sku" : "ZTNI-E-10000-STD", 
        "currency_code" : "BRL", 
        "available" : true, 
        "type" : "reward", 
        "countries" : [ 
         "BR" 
        ], 
        "is_variable" : false, 
        "denomination" : "10000" 
       } 
      ] 
     } 
    ] 

} 

在此JSON数据,是我将只取获得MongoDB中只有MIN_PRICE值的记录有MIN_PRICE:1,这里的一些记录没有MIN_PRICE它有面额,所以我只需要有mongodb的min_price查询。

预先感谢您的支持

+1

请加什么你到目前为止所尝试过的。 – Veeram

回答

0

这将获取整个文件,其中有min_price : 1

db.collection.find({"brands.rewards.min_price" : 1}) 

如果你只想要其价格为1

db.collection.aggregate([{"$unwind" : "$brands"},{"$unwind" : "$rewards"},{$match : {brands.rewards.min_price : 1}}]) 

如果行得奖励不能满足您的要求,请张贴输出你想

+0

我想照片的所有记录是有min_price是1 –

+0

是的第二个查询会给你,请张贴您的输出 –

+0

而执行得到这个错误“放松不是一个运算符” –