How to query data from nested document in mongodb? - mongodb
I'm struggling with this nested document too much. I tried to read the document and also follow other SO responses to see if it works for me, but I'm not getting the results that I'm looking for. I want to extract some information from a big nested document.
DATA
I've uploaded the data to mongo playground. https://mongoplayground.net/p/7nbLtXMlFMx
{"_id":{"$oid":"5f7f29259ac5883ec5eed1ec"},"name":"Walmart","page":{"name":"body","config":{},"children":[{"name":"company-title","config":{"title":"Walmart","rank":"1","franchiseTitle":"Fortune 500","franchisePermalink":"https://fortune.com/fortune500/2020/","parentPermalink":"https://fortune.com/company/walmart/"},"children":[]},{"name":"company-single-pagination","config":{"prevName":"","prevLink":"","prevRank":"","nextName":"Amazon.com","nextLink":"https://fortune.com/company/amazon-com/fortune500/","nextRank":2,"hideRanking":false,"rank":"1","franchiseTitle":"Fortune 500"},"children":[]},{"name":"company-hero","config":{"description":"After years of investment in its technology and stores, Walmart has indisputably emerged as a strong No. 2 to Amazon in U.S. e-commerce, with sales up 37% last year. But as the initial weeks of the novel coronavirus pandemic have shown, Walmart’s 4,600 U.S. stores have proved to be an effective weapon by allowing curbside pickup for online orders at a time shoppers want to limit time in stores—but still want their orders quickly. That sentiment is not likely to change anytime soon. Walmart Inc.’s Sam’s Club is finding renewed energy, too. Walmart is benefiting from focusing on select overseas markets, such as India and China, rather than competing everywhere."},"children":[{"name":"brightcove-video","config":{"accountId":"2111767321001","disableAds":false,"disableAutoplay":false,"disableContinuousPlay":false,"disableViewplay":false,"isLeadVideo":false,"loop":false,"playerId":"HDNR3TkSj","stickyPlayerOff":false,"silentlyAutoplay":true,"videoId":{"$numberLong":"6156999393001"},"section":""},"children":[]}]},{"name":"company-about-wrapper","config":{},"children":[{"name":"company-additional-media","config":{},"children":[]},{"name":"advertising-slot","config":{"align":"center","lazyload":true,"useDynamicChannel":true,"placementName":"InStream","slotId":"InStream0","targeting":{"placement_name":"InStream","index":1}},"children":[]},{"name":"company-information","config":{"title":"Company information","country":"U.S.","headquarters":"Bentonville, Ark.","industry":"General Merchandise","ceo":"C. Douglas McMillon","website":"https://www.stock.walmart.com","companyType":"Public","ticker":"WMT","revenues":"523964","profits":"14881","marketValue":"389244","employees":"2200000","updated":"9/21/20","footnote":"Market value as of Sept. 15, 2020."},"children":[]},{"name":"advertising-slot","config":{"align":"center","lazyload":true,"useDynamicChannel":true,"placementName":"InStream","slotId":"InStream1","targeting":{"placement_name":"InStream","index":2}},"children":[]},{"name":"company-information","config":{"title":"Company information","country":"U.S.","headquarters":"Bentonville, Ark.","industry":"General Merchandise","ceo":"C. Douglas McMillon","website":"https://www.stock.walmart.com","companyType":"Public","ticker":"WMT","revenues":"523964","profits":"14881","marketValue":"389244","employees":"2200000","updated":"9/21/20","footnote":"Market value as of Sept. 15, 2020."},"children":[]},{"name":"company-table-wrapper","config":{},"children":[{"name":"company-data-table","config":{"title":"Key Financials (Last Fiscal Year)","tableIndex":0,"table":{"franchiseId":2814606,"title":"Key Financials (Last Fiscal Year)","rows":[{"value":"Revenues ($M)","pctChange":"Revenue Percent Change"},{"value":"Profits ($M)","pctChange":"Profits Percent Change"},{"value":"Assets ($M)"},{"value":"Total Stockholder Equity ($M)"}],"showValue":"show_value","valueHeader":"$ millions","showPctChange":"show_pct_change","pctChangeHeader":"% change"},"updated":"","data":[{"key":"f500_revenues","value":"523964","fieldMeta":{"franchiseId":2814606,"title":"Revenues ($M)","altTitle":"Revenues ($M)","description":"Companies are ranked by total revenues for their respective fiscal years.","type":"Money","saveIn":"post_meta","importField":"f500_revenues","sortable":"sortable","order":"desc"}},{"key":"f500_profits","value":"14881","fieldMeta":{"franchiseId":2814606,"title":"Profits ($M)","altTitle":"Profits ($M)","description":"Net income after extraordinary charges for a company's respective fiscal year.","type":"Money","decimals":"1","saveIn":"post_meta","importField":"f500_profits","sortable":"sortable","order":"desc"}},{"key":"assets","value":"236495","fieldMeta":{"franchiseId":2814606,"title":"Assets ($M)","altTitle":"Assets ($M)","description":"Total assets on a company's fiscal year-end balance sheet.","type":"Money","saveIn":"post_meta","importField":"assets","sortable":"sortable","order":"desc"}},{"key":"totshequity","value":"74669","fieldMeta":{"franchiseId":2814606,"title":"Total Stockholder Equity ($M)","type":"Money","saveIn":"post_meta","importField":"totshequity"}}],"footnote":"","themeName":"half","change":[{"key":"revchange","value":"1.9","fieldMeta":{"franchiseId":2814606,"title":"Revenue Percent Change","altTitle":"Revenue Change","description":"Increase/decrease in revenues between the current and prior fiscal years.","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"revchange","sortable":"sortable","order":"desc"}},{"key":"prftchange","value":"123.1","fieldMeta":{"franchiseId":2814606,"title":"Profits Percent Change","altTitle":"Profit Change","description":"Increase/decrease in profits between the current and prior fiscal years.","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"prftchange","sortable":"sortable","order":"desc"}},{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false}],"changeHeader":"% change","valueHeader":"$ millions","showChange":true},"children":[]},{"name":"company-data-table","config":{"title":"Profit Ratios","tableIndex":1,"table":{"franchiseId":2814606,"title":"Profit Ratios","rows":[{"value":"Profit as % of Revenues"},{"value":"Profits as % of Assets"},{"value":"Profits as % of Stockholder Equity"}],"showValue":"show_value","pctChangeHeader":"% change"},"updated":"","data":[{"key":"prftpctsls","value":"2.8","fieldMeta":{"franchiseId":2814606,"title":"Profit as % of Revenues","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"prftpctsls"}},{"key":"prftpctasts","value":"6.3","fieldMeta":{"franchiseId":2814606,"title":"Profits as % of Assets","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"prftpctasts"}},{"key":"prftpctseqty","value":"19.9","fieldMeta":{"franchiseId":2814606,"title":"Profits as % of Stockholder Equity","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"prftpctseqty"}}],"footnote":"","themeName":"half","change":[{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false}],"changeHeader":"% change","valueHeader":"","showChange":false},"children":[]},{"name":"company-data-table","config":{"title":"Earnings Per Share (Last Fiscal Year)","tableIndex":2,"table":{"franchiseId":2814606,"title":"Earnings Per Share (Last Fiscal Year)","rows":[{"value":"Earnings Per Share ($)"},{"value":"EPS % Change (from 2018)"},{"value":"EPS % Change (5 year annual rate)"},{"value":"EPS % Change (10 year annual rate)"}],"showValue":"show_value","pctChangeHeader":"% change"},"updated":"","data":[{"key":"eps","value":"5.19","fieldMeta":{"franchiseId":2814606,"title":"Earnings Per Share ($)","altTitle":"EPS","type":"Number","decimals":"2","saveIn":"post_meta","importField":"eps"}},{"key":"epschange","value":"129.6","fieldMeta":{"franchiseId":2814606,"title":"EPS % Change (from 2018)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"epschange"}},{"key":"eps5yr","value":"0.5","fieldMeta":{"franchiseId":2814606,"title":"EPS % Change (5 year annual rate)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"eps5yr"}},{"key":"eps10yr","value":"3.4","fieldMeta":{"franchiseId":2814606,"title":"EPS % Change (10 year annual rate)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"eps10yr"}}],"footnote":"","themeName":"half","change":[{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false}],"changeHeader":"% change","valueHeader":"","showChange":false},"children":[]},{"name":"company-data-table","config":{"title":"Total Return","tableIndex":3,"table":{"franchiseId":2814606,"title":"Total Return","rows":[{"value":"Total Return to Investors (2019)"},{"value":"Total Return to Investors (5 year, annualized)"},{"value":"Total Return to Investors (10 year, annualized)"}],"showValue":"show_value","pctChangeHeader":"% change"},"updated":"","data":[{"key":"totrti","value":"30.3","fieldMeta":{"franchiseId":2814606,"title":"Total Return to Investors (2019)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"totrti"}},{"key":"totrti5yr","value":"9.4","fieldMeta":{"franchiseId":2814606,"title":"Total Return to Investors (5 year, annualized)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"totrti5yr"}},{"key":"totrti10yr","value":"11","fieldMeta":{"franchiseId":2814606,"title":"Total Return to Investors (10 year, annualized)","type":"Percent","decimals":"1","saveIn":"post_meta","importField":"totrti10yr"}}],"footnote":"","themeName":"half","change":[{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false},{"key":null,"value":"","fieldMeta":false}],"changeHeader":"% change","valueHeader":"","showChange":false},"children":[]}]},{"name":"company-qlik","config":{"title":"Take a unique journey through the F500","eyebrowLabel":"fortune + qlik","description":"<p>We teamed up with Qlik, the Official Analytics Partner of the Fortune 500, to bring to life the shifting fortunes of iconic companies and sectors in an interactive data visualization.</p>\n","link":"https://qlik.fortune.com/"},"children":[{"name":"image","config":{"aspectRatio":0.6666666666666666,"attachmentId":2862622,"alt":"","caption":"","crops":[],"height":300,"imageSize":"qlik_2x3","lazyload":true,"lqipSrc":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-2x3-1.gif?quality=60&resize=60,40","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"resize":[181,296]}}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-2x3-1.gif","srcset":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-2x3-1.gif?resize=362,592 0w,https://content.fortune.com/wp-content/uploads/2020/05/qlik-2x3-1.gif?resize=181,296 0w","url":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-2x3-1.gif","useBasicImg":false,"usingDataFallback":false,"width":200,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"100vw"},"children":[]},{"name":"image","config":{"aspectRatio":1.5,"attachmentId":2862623,"alt":"","caption":"","crops":[],"height":200,"imageSize":"qlik_3x2","lazyload":true,"lqipSrc":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-3x2-1.gif?quality=60&resize=60,90","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"resize":[181,121]}}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-3x2-1.gif","srcset":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-3x2-1.gif?resize=362,242 0w,https://content.fortune.com/wp-content/uploads/2020/05/qlik-3x2-1.gif?resize=181,121 0w","url":"https://content.fortune.com/wp-content/uploads/2020/05/qlik-3x2-1.gif","useBasicImg":false,"usingDataFallback":false,"width":300,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"100vw"},"children":[]}]},{"name":"company-rank-history-wrapper","config":{},"children":[{"name":"company-interactives-wrapper","config":{},"children":[{"name":"interactive","config":{"heading":"Walmart Rank History","interactiveUrl":"https://interactives.fortune.com/f500-dataviz-2020/rank_chart_single_co/index.html?guid=2255","refinitivUrl":"https://interactives.fortune.com/f500-dataviz-2020/rank_chart_single_co/index.html?ric","themeName":"company"},"children":[]}]}]},{"name":"company-historical","config":{"franchiseId":2814606,"companyId":2818204},"children":[]},{"name":"sidebar","config":{"themeName":"right"},"children":[{"name":"company-data-store-cta","config":{"buttonText":"Purchase Now","text":"Leads, insights, and financial data for the FORTUNE 500, FORTUNE 1000, and Global 500 companies.","url":"/data-store/"},"children":[]},{"name":"advertising-slot","config":{"align":"center","lazyload":true,"useDynamicChannel":false,"placementName":"RightRailFlex","slotId":"RightRailFlex0","targeting":{"placement_name":"RightRailFlex","index":1}},"children":[]}]}]},{"name":"company-ranking-list","config":{"heading":"Lists ranking","title":"Walmart"},"children":[{"name":"company-ranking-list-item","config":{"title":"Change the World","permalink":"https://fortune.com/company/walmart/change-the-world/","excerpt":"As we face unprecedented collective challenges, cooperation has become a business superpower.","year":"2020","color":"#f3eee2","logo":"","rank":"9","itemId":2818204},"children":[{"name":"image","config":{"aspectRatio":false,"attachmentId":2885302,"alt":"","caption":"","crops":[],"height":1920,"imageSize":"franchise-logo","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"w":[115]},"descriptor":115}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2020/09/CTW20.change-the-world-Logo2-1.jpg","srcset":"https://content.fortune.com/wp-content/uploads/2020/09/CTW20.change-the-world-Logo2-1.jpg?w=230 230w,https://content.fortune.com/wp-content/uploads/2020/09/CTW20.change-the-world-Logo2-1.jpg?w=115 115w","url":"https://content.fortune.com/wp-content/uploads/2020/09/CTW20.change-the-world-Logo2-1.jpg","useBasicImg":false,"usingDataFallback":false,"width":2880,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"115px"},"children":[]}]},{"name":"company-ranking-list-item","config":{"title":"Global 500","permalink":"https://fortune.com/company/walmart/global500/","excerpt":"This year's Global 500 generated $33.3 trillion in revenues and $2.1 trillion in profits.","year":"2020","color":"#ffe500","logo":"","rank":"1","itemId":2818204},"children":[{"name":"image","config":{"aspectRatio":false,"attachmentId":2864400,"alt":"G500-Featured Image-Logo-2020","caption":"","crops":[],"height":1920,"imageSize":"franchise-logo","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"w":[115]},"descriptor":115}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2020/08/G500-Featured-Image-Logo-2020.jpg","srcset":"https://content.fortune.com/wp-content/uploads/2020/08/G500-Featured-Image-Logo-2020.jpg?w=230 230w,https://content.fortune.com/wp-content/uploads/2020/08/G500-Featured-Image-Logo-2020.jpg?w=115 115w","url":"https://content.fortune.com/wp-content/uploads/2020/08/G500-Featured-Image-Logo-2020.jpg","useBasicImg":false,"usingDataFallback":false,"width":2880,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"115px"},"children":[]}]},{"name":"company-ranking-list-item","config":{"title":"Fortune 500","permalink":"https://fortune.com/company/walmart/fortune500/","excerpt":"This year's Fortune 500 marks the 66th running of the list.","year":"2020","color":"#000000","logo":"","rank":"1","itemId":2818204},"children":[{"name":"image","config":{"aspectRatio":false,"attachmentId":2817676,"alt":"F500-2020-Logo","caption":"","crops":[],"height":1920,"imageSize":"franchise-logo","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"w":[115]},"descriptor":115}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2020/05/F500-2020-Logo.jpg","srcset":"https://content.fortune.com/wp-content/uploads/2020/05/F500-2020-Logo.jpg?w=230 230w,https://content.fortune.com/wp-content/uploads/2020/05/F500-2020-Logo.jpg?w=115 115w","url":"https://content.fortune.com/wp-content/uploads/2020/05/F500-2020-Logo.jpg","useBasicImg":false,"usingDataFallback":false,"width":2880,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"115px"},"children":[]}]},{"name":"company-ranking-list-item","config":{"title":"World’s Most Admired Companies","permalink":"https://fortune.com/worlds-most-admired-companies/2020/walmart/","excerpt":"For an astounding 13th straight year, Apple claims the top spot in Fortune’s annual ranking of corporate reputation, based on a survey of almost 3,800 executives, directors, and analysts.","year":"2020","color":"#000000","logo":"","rank":"18","itemId":2753766},"children":[{"name":"image","config":{"aspectRatio":false,"attachmentId":2757757,"alt":"","caption":"","crops":[],"height":356,"imageSize":"franchise-logo","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":0,"retina":true,"showCaption":false,"sources":[{"default":true,"transforms":{"w":[115]},"descriptor":115}],"sourceTags":[],"src":"https://content.fortune.com/wp-content/uploads/2019/01/wma_logo.jpg","srcset":"https://content.fortune.com/wp-content/uploads/2019/01/wma_logo.jpg?w=230 230w,https://content.fortune.com/wp-content/uploads/2019/01/wma_logo.jpg?w=115 115w","url":"https://content.fortune.com/wp-content/uploads/2019/01/wma_logo.jpg","useBasicImg":false,"usingDataFallback":false,"width":536,"fallbackImageUrl":"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","picture":false,"sizes":"115px"},"children":[]}]}]},{"name":"company-latest-news-wrapper","config":{"title":"Latest news for Walmart"},"children":[{"name":"advertising-slot","config":{"align":"center","lazyload":true,"useDynamicChannel":true,"placementName":"InStream","slotId":"InStream2","targeting":{"placement_name":"InStream","index":3}},"children":[]},{"name":"company-latest-news","config":{},"children":[{"name":"content-item","config":{"themeName":"company_latest_news","timeago":"","isNativoTout":false,"eyebrowSectionLabel":"Conferences","eyebrowSectionLink":"https://fortune.com/section/conferences/","eyebrowTagLabel":"Most Powerful Women","eyebrowTagLink":"https://fortune.com/tag/most-powerful-women/","title":"How Sam’s Club helped small businesses through COVID","permalink":"https://fortune.com/2020/10/01/sams-club-ceo-kathryn-mclay-small-business-most-powerful-women/","id":2894934,"excerpt":"The pandemic has sped up tech innovation at the warehouse retailer.","publishDateIso8601":"2020-10-01T16:53:55-04:00","type":"post"},"children":[{"name":"image","config":{"aspectRatio":0.5625,"attachmentId":2891872,"alt":"","caption":"","crops":[],"height":0,"imageSize":"full","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":2894934,"retina":true,"showCaption":false,"sources":[],"sourceTags":[],"src":"","srcset":"","url":"","useBasicImg":false,"usingDataFallback":false,"width":0},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/phil-wahba/","name":"Phil Wahba"},"children":[]}]},{"name":"content-item","config":{"themeName":"company_latest_news","timeago":"","isNativoTout":false,"eyebrowSectionLabel":"Retail","eyebrowSectionLink":"https://fortune.com/section/retail/","eyebrowTagLabel":"Walmart","eyebrowTagLink":"https://fortune.com/tag/walmart/","title":"Walmart unveils new store design inspired by Amazon and airports","permalink":"https://fortune.com/2020/09/30/walmart-new-store-design-app-online-pickup-amazon-airports/","id":2893828,"excerpt":"The discount chain wants people to use its Walmart app more and to be able to get in and out faster.","publishDateIso8601":"2020-09-30T11:41:27-04:00","type":"post"},"children":[{"name":"image","config":{"aspectRatio":0.5625,"attachmentId":2893884,"alt":"","caption":"","crops":[],"height":0,"imageSize":"full","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":2893828,"retina":true,"showCaption":false,"sources":[],"sourceTags":[],"src":"","srcset":"","url":"","useBasicImg":false,"usingDataFallback":false,"width":0},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/phil-wahba/","name":"Phil Wahba"},"children":[]}]},{"name":"content-item","config":{"themeName":"company_latest_news","timeago":"","isNativoTout":false,"eyebrowSectionLabel":"Conferences","eyebrowSectionLink":"https://fortune.com/section/conferences/","eyebrowTagLabel":"MPW Summit","eyebrowTagLink":"https://fortune.com/tag/mpw-summit/","title":"3 ways Walmart and Home Depot execs think retail will change for good","permalink":"https://fortune.com/2020/09/29/retail-coronavirus-pandemic-home-depot-walmart-execs-covid-19/","id":2893036,"excerpt":"We won't go back to pre-pandemic behavior, top execs from Walmart and Home Depot predicted at Fortune's virtual Most Powerful Women's conference Tuesday. ","publishDateIso8601":"2020-09-29T18:12:00-04:00","type":"post"},"children":[{"name":"image","config":{"aspectRatio":0.5625,"attachmentId":2890633,"alt":"","caption":"","crops":[],"height":0,"imageSize":"full","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":2893036,"retina":true,"showCaption":false,"sources":[],"sourceTags":[],"src":"","srcset":"","url":"","useBasicImg":false,"usingDataFallback":false,"width":0},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/anne-sraders/","name":"Anne Sraders"},"children":[]}]},{"name":"content-item","config":{"themeName":"company_latest_news","timeago":"","isNativoTout":false,"eyebrowSectionLabel":"Environment","eyebrowSectionLink":"https://fortune.com/section/environment/","eyebrowTagLabel":"Walmart","eyebrowTagLink":"https://fortune.com/tag/walmart/","title":"Walmart says it will eliminate emissions from global operations by 2040","permalink":"https://fortune.com/2020/09/21/walmart-emissions-global-reduction/","id":2888827,"excerpt":"The cuts, while substantial, will only cover its own operation's emissions—5% of the total. ","publishDateIso8601":"2020-09-21T06:52:56-04:00","type":"post"},"children":[{"name":"image","config":{"aspectRatio":0.5625,"attachmentId":2888833,"alt":"","caption":"","crops":[],"height":0,"imageSize":"full","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":2888827,"retina":true,"showCaption":false,"sources":[],"sourceTags":[],"src":"","srcset":"","url":"","useBasicImg":false,"usingDataFallback":false,"width":0},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/stephen-stapczynski/","name":"Stephen Stapczynski"},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/akshat-rathi/","name":"Akshat Rathi"},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/bloomberg/","name":"Bloomberg"},"children":[]}]},{"name":"content-item","config":{"themeName":"company_latest_news","timeago":"","isNativoTout":false,"eyebrowSectionLabel":"Retail","eyebrowSectionLink":"https://fortune.com/section/retail/","eyebrowTagLabel":"Food Waste","eyebrowTagLink":"https://fortune.com/tag/food-waste/","title":"Exclusive: Startup Apeel is launching ‘plastic-free’ cucumbers at Walmart to cut back on waste","permalink":"https://fortune.com/2020/09/21/apeel-cucumbers-walmart-plastic-food-waste/","id":2888394,"excerpt":"Apeel’s English cucumbers are coated in a plant-based material that extends shelf life without the need for single-use plastic.","publishDateIso8601":"2020-09-21T06:00:31-04:00","type":"post"},"children":[{"name":"image","config":{"aspectRatio":0.5625,"attachmentId":2888387,"alt":"","caption":"","crops":[],"height":0,"imageSize":"full","lazyload":true,"lqipSrc":"data: image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7","postId":2888394,"retina":true,"showCaption":false,"sources":[],"sourceTags":[],"src":"","srcset":"","url":"","useBasicImg":false,"usingDataFallback":false,"width":0},"children":[]},{"name":"byline","config":{"link":"https://fortune.com/author/beth-kowitt/","name":"Beth Kowitt"},"children":[]}]}]},{"name":"company-latest-videos","config":{"tags":["Walmart"],"title":"Walmart"},"children":[]},{"name":"sidebar","config":{"themeName":"right"},"children":[{"name":"advertising-slot","config":{"align":"center","lazyload":true,"useDynamicChannel":false,"placementName":"RightRailFlex","slotId":"RightRailFlex1","targeting":{"placement_name":"RightRailFlex","index":2}},"children":[]}]}]}]}}
What I want to extract is the config from children of page where the name is company-information and description from name company-hero. I read the articles and documentation, and I can do what I want if the document is not as nested. But I'm completely lost on how to extract those info that I'm looking from. This is the first time working on Mongodb for me to this extent. I had done something very basic before.
I tried
db.collection.find(
{"page.children.3.children.2.name": {"$eq": "company-information"}},
{"page.children.3.children.2": 1}
)
but got empty result
Output
There are about 1000 rows(? Not sure if I can call it rows). The part that I'm interested in is pulling the page.children[3].children[2] where the name is company-information. So the result should be the following:
"config": {
"ceo": "C. Douglas McMillon",
"companyType": "Public",
"country": "U.S.",
"employees": "2200000",
"footnote": "Market value as of Sept. 15, 2020.",
"headquarters": "Bentonville, Ark.",
"industry": "General Merchandise",
"marketValue": "389244",
"profits": "14881",
"revenues": "523964",
"ticker": "WMT",
"title": "Company information",
"updated": "9/21/20",
"website": "https://www.stock.walmart.com"
}
You can do (almost!) anything with an aggregate query. In your case I suggest using $unwind to convert the lists to onjects, then $match on your target field(s), $project to trim down the output, $replaceRoot to simplify the structure and $limit for good measure as there's actually 2 records that match your criteria.
https://mongoplayground.net/p/UsKeqA0aWYK
db.collection.aggregate([
{
"$unwind": "$page.children"
},
{
"$unwind": "$page.children.children"
},
{
"$match": {
"page.children.children.name": "company-information"
}
},
{
"$project": {
"_id": 0,
"page.children.children.config": 1
}
},
{
"$replaceRoot": {
"newRoot": "$page.children.children"
}
},
{
"$limit": 1
}
])
Related
ArangoDB Date Math - Month difference
Utilizing the DATE_SUBTRACT function in AQL, when handling dates near the end of the month, Arango seems to subtract 30 days instead of returning the actual previous month. e.g.: for mo in 0..11 let month = date_subtract(date_now(),count,"month") return month returns [ "2016-08-31T20:30:24.440Z", "2016-07-31T20:30:24.441Z", "2016-07-01T20:30:24.441Z", "2016-05-31T20:30:24.441Z", "2016-05-01T20:30:24.441Z", "2016-03-31T20:30:24.441Z", "2016-03-02T20:30:24.441Z", "2016-01-31T20:30:24.441Z", "2015-12-31T20:30:24.441Z", "2015-12-01T20:30:24.441Z", "2015-10-31T20:30:24.441Z", "2015-10-01T20:30:24.441Z" ] As you can see, this returns July twice, May twice, March twice, December twice, and October twice. I actually just need the prior 12 months. The list I'd like is: [ "2016-08-01T00:00:00.000Z", "2016-07-01T00:00:00.000Z", "2016-06-01T00:00:00.000Z", "2016-05-01T00:00:00.000Z", "2016-04-01T00:00:00.000Z", "2016-03-01T00:00:00.000Z", "2016-02-01T00:00:00.000Z", "2016-01-01T00:00:00.000Z", "2015-12-01T00:00:00.000Z", "2015-11-01T00:00:00.000Z", "2015-10-01T00:00:00.000Z", "2015-09-01T00:00:00.000Z" ] How in AQL could I ensure I always get the actual previous month instead of simply 30 days in the past? I fear that the date_subtract function won't handle leap years or 31sts.
It's hacky, but I managed to accomplish what I was after with this: for mo in 0..11 return date_subtract(concat(left(date_iso8601(date_now()),7),'-01T00:00:00.000Z'), mo, "month") Resulting in: [ "2016-08-01T00:00:00.000Z", "2016-07-01T00:00:00.000Z", "2016-06-01T00:00:00.000Z", "2016-05-01T00:00:00.000Z", "2016-04-01T00:00:00.000Z", "2016-03-01T00:00:00.000Z", "2016-02-01T00:00:00.000Z", "2016-01-01T00:00:00.000Z", "2015-12-01T00:00:00.000Z", "2015-11-01T00:00:00.000Z", "2015-10-01T00:00:00.000Z", "2015-09-01T00:00:00.000Z" ] I would love a simpler solution to this, so please let me know if there is one. All those functions are a bunch of overhead.
How to handle with date range in mathematica?
In google trends there is possibility to export data as CSV. Obtained CSV has the following structure: Week,subject 1, subject 2 2004-01-04 - 2004-01-10,13,6 2004-01-11 - 2004-01-17,9,9 2004-01-18 - 2004-01-24,11,4 I know that there is DateObject[], but it contain only one date. I want to obtain stepped chart of subjects 1 and 2 in time domain, and calculate correlation of them in range between two given dates. My problem is: how structure of data, should I use to represent time range?
As google trends calls the time variable "week" take StringTake["2004-01-04 - 2004-01-10", 10] to get the first day of the range, then use DateList[{"2004-01-04", {"Year", "Month", "Day"}}] to create a date list and DateString[{2004, 1, 4, 0, 0, 0}, {"Week"}] to express the time in terms of the calendar week of the year. So, the function RangeToWeek[timerangestring_] := DateString[ DateList[{ StringTake[timerangestring, 10], {"Year", "Month", "Day"}}], {"Week"}] gives for the firs date in your list 01, because the time span from 04.01.2004 to 10.01.2004 corresponds to the first callendar week of that year.
How to Round and Format Mail Merge Number
I have an amount that fluctuates from 1 million to over a billion and want to show the result as $1.5 million or $1.5 billion using the field codes in Word 2013 for a mail merge. (ie. 1,500,000 should display $1.5 million and 1,500,000,000 should display as $1.5 billion.) I have this so far: {=int({MERGEFIELD AreaSales})/100000000 \# $,0.0} Which gives me close to what I'm looking for $1.5 but without accounting for an amount in the millions or billions and the proper label. Thanks in advance!
I don't understand exactly what you're asking - you should always provide examples of what you want to have. I'm assuming what you mean is you want to see the word "million" or "billion", as appropriate. This can be done using a separate IF field: { IF { MERGEFIELD AreaSales } > 999999.99 "{ IF { MERGEFIELD AreaSales } < 1000000000 "million" "billion" }" "" }
MongoDB, Atomic Level Operation
i want to ask some info related findAndModify in MongoDB. As i know the query is "isolated by document". This mean that if i run 2 findAndModify like this: {a:1},{set:{status:"processing", engine:1}} {a:1},{set:{status:"processing", engine:2}} and this query potentially can effect 2.000 documents then because there are 2-query (2engine) then maybe that some document will have "engine:1" and someother "engine:2". I don't think findAndModify will isolate the "first query". In order to isolate the first query i need to use $isolated. Is everything write what i have write? UPDATE - scenario The idea is to write an proximity engine. The collection User has 1000-2000-3000 users, or millions. 1 - Order by Nearest from point "lng,lat" 2 - in NodeJS i make some computation that i CAN'T made in MongoDB 3 - Now i will group the Users in "UserGroup" and i write an Bulk Update When i have 2000-3000 Users, then this process (from 1 to 3) take time. So i want to have Multiple Thread in parallel. Parallel thread mean parallel query. This can be a problem since Query3 can take some users of Query1. If this happen, then at point (2) i don't have the most nearest Users but the most nearest "for this query" because maybe another query have take the rest of Users. This can create maybe that some users in New York is grouped with users of Los Angeles. UPDATE 2 - scenario I have an collection like this: {location:[lng,lat], name:"1",gender:"m", status:'undone'} {location:[lng,lat], name:"2",gender:"m", status:'undone'} {location:[lng,lat], name:"3",gender:"f", status:'undone'} {location:[lng,lat], name:"4",gender:"f", status:'done'} What i should be able to do, is create 'Group' of users by grouping by the most nearest. Each Group have 1male+1female. In the example above, i'm expecting to have only 1 group (user1+user3) since there are Male+Female and are so near each other (user-2 is also Male, but is far away from User-3 and also user-4 is also Female but have status 'done' so is already processed). Now the Group are created (only 1 group) so the 2users are marked as 'done' and the other User-2 is marked as 'undone' for future operation. I want to be able to manage 1000-2000-3000 users very fast. UPDATE 3 : from community Okay now. Can I please try to summarise your case. Given your data, you want to "pair" male and female entries together based on their proximity to each other. Presumably you don't want to do every possible match but just set up a list of general "recommendations", and let's say 10 for each user by the nearest location. Now I'd have to be stupid to not see the full direction of where this is going, but does this sum up the basic initial problem statement. Process each user, find their "pairs", mark them as "done" once paired and exclude them from other pairings by combination where complete?
This is a non-trivial problem and can not be solved easily. First of all, an iterative approach (which admittedly was my first one) may lead to wrong results. Given we have the following documents { _id: "A", gender: "m", location: { longitude: 0, latitude: 1 } } { _id: "B", gender: "f", location: { longitude: 0, latitude: 3 } } { _id: "C", gender: "m", location: { longitude: 0, latitude: 4 } } { _id: "D", gender: "f", location: { longitude: 0, latitude: 9 } } With an iterative approach, we now would start with "A" and calculate the closest female, which, of course would be "B" with a distance of 2. However, in fact, the closest distance between a male and a female would be 1 (distance from "B" to "C"). But even when we found this, that would leave the other match, "A" and "D", at a distance of 8, where, with our previous solution, "A" would have had a distance of only 2 to "B". So we need to decide what way to go Naively iterate over the documents Find the lowest sum of distances between matching individuals (which itself isn't trivial to solve), so that all participants together have the shortest travel. Matching only participants within an acceptable distance Do some sort of divide and conquer and match participants within a certain radius of a common landmark (say cities, for example) Solution 1: Naively iterate over the documents var users = db.collection.find(yourQueryToFindThe1000users); // We can safely use an unordered op here, // which has greater performance. // Since we use the "done" array do keep track of // the processed members, there is no drawback. var pairs = db.pairs.initializeUnorderedBulkOp(); var done = new Array(); users.forEach( function(currentUser){ if( done.indexOf(currentUser._id) == -1 ) { return; } var genderToLookFor = ( currentUser.gender === "m" ) ? "f" : "m"; // using the $near operator, // the returned documents automatically are sorted from nearest // to farest, and since findAndModify returns only one document // we get the closest matching partner. var nearPartner = db.collection.findAndModify( query: { status: "undone", gender: genderToLookFor, $near: { $geometry: { type: "Point" , coordinates: currentUser.location } } }, update: { $set: { "status":"done" } }, fields: { _id: 1} ); // Obviously, the current use already is processed. // However, we store it for simplifying the process of // setting the processed users to done. done.push(currentUser._id, nearPartner._id); // We have a pair, so we store it in a bulk operation pairs.insert({ _id:{ a: currentUser._id, b: nearPartner._id } }); } ) // Write the found pairs pairs.execute(); // Mark all that are unmarked by now as done db.collection.update( { _id: { $in: done }, status: "undone" }, { $set: { status: "done" } }, { multi: true } ) Solution 2: Find the smallest sum of distances between matches This would be the ideal solution, but it is extremely complex to solve. We need to all members of one gender, calculate all distances to all members of the other gender and iterate over all possible sets of matches. In our example it is quite simple, since there are only 4 combinations for any given gender. Thinking of it twice, this might be at least a variant of the traveling salesman problem (MTSP?). If I am right with that, the number of combinations should be for all n>2, where n is the number of possible pairs. and hence for n=10 and an astonishing for n=25 That's 7.755 quadrillion (long scale) or 7.755 septillion (short scale). While there are approaches to solving this kind of problem, the world record is somewhere in the range of 25,000 nodes using massive amounts of hardware and quite tricky algorithms. I think for all practical purposes, this "solution" can be ruled out. Solution 3 In order to prevent the problem that people might be matched with unacceptable distances between them and depending on your use case, you might want to match people depending on their distance to a common landmark (where they are going to meet, for example the next bigger city). For our example assume we have cities at [0,2] and [0,7]. The distance (5) between the cities hence has to be our acceptable range for matches. So we do a query for each city db.collection.find({ $near: { $geometry: { type: "Point" , coordinates: [ 2 , 0 ] }, $maxDistance: 5 }, status: "done" }) and iterate over the results naively. Since "A" and "B" would be the first in the result set, they would be matched and done. Bad luck for "C" here, as no girl is left for him. But when we do the same query for the second city he gets his second chance. Ok, his travel gets a bit longer, but hey, he got a date with "D"! To find the respective distances, take a fixed set of cities (towns, metropolitan areas, whatever your scale is), order them by location and set each cities radius to the bigger of the two distances to their immediate neighbors. This way, you get overlapping areas. So even when a match can not be found in one place, it may be found on others. Iirc, Google Maps allows it to grab the cities of a nation based on their size. An easier way would be to let people choose their respective city. Notes The code shown is not production ready and needs to be refined. Instead of using "m" and "f" for denoting a gender, I suggest using 1 and 0: Can still be easily mapped, but needs less space to save. Same goes for status. I think the last solution is the best, optimizing distances some wayish and keeping the chances high for a match.
drools - get index of item in collection
I have a restaurant app and have a rule where a 20% discount needs to be offered for every 2nd ice-cream. So, If bill has 2 icecreams, 20% discount on the 2nd icecream If bill has 3 icecreams, still 20% discount on the 2nd icecream If bill has 4 icecreams, 20% discount on the 2nd and 4th icecreams I have a collection called $bill.items which contains each individual item in the bill. How can I write this rule in Drools given that there seems to be no way to access the index of an element in a collection.
Just collect them up and apply the discounts on the right-hand-side: rule "Discount multiple ice creams" when $bill : Bill() $iceCreams : ArrayList( size > 1 ) from $bill.items then for (int i = 0; i < $iceCreams.size(); i++) { if (i % 2 == 0) { // Apply a discount } } end Or if each bill item is available in working memory, the following can be used on the LHS to collect them: $iceCreams : ArrayList( size > 1 ) from collect( BillItem(type == "Ice Cream") ) You may need to re-sort the list you have collected, based on each item's index within the bill. Although, does the order of the items on a single bill really matter? The order in which items are entered on a bill is a rather unusual basis for a discount. As a customer buying 2 ice creams of differing price, I would ask for the cheapest item first because I will get a bigger discount on the second ice cream added to my bill. Hence why such discounts are usually applied to the N cheapest items. i.e. If 4 ice creams are purchased, then the 2 cheapest are discounted. Also, are ice creams different prices? If each ice cream is the same price, then all you really need to know is how many need to be discounted.