How do I use Map/Reduce in MongoDB?(如何在 MongoDB 中使用 Map/Reduce?)
问题描述
我很难理解 map/reduce 在 MongoDB 中的工作原理.我有一个包含以下字段的集合:areacode, state, County, zip, city, lat, lon
列出了美国的每个邮政编码以及相应的县、州等.
I'm having trouble wrapping my head around how map/reduce works in MongoDB. I have a collection with the fields: areacode, state, county, zip, city, lat, lon
that lists every zip code in the US along with the corresponding county, state, etc.
我希望能够查询给定州的所有县或市.所以基本上某种查询会查找State=MI"的所有记录.在这种情况下,大约有 900 条记录被返回.如何按县对它们进行分组,以便获得该州的 83 个县?我不想使用 distinct,因为我希望能够按字母顺序对它们进行排序,并且可能还可以提取纬度/经度.
I'd like to be able to query say all the counties or cities in a given state. So basically some sort of a query that looks for all records where "State=MI". In this case, there are about 900 records returned. How do I group them by county so that I just get the 83 counties for that state? I don't want to use distinct as I would like to be able to order them in alphabetical order and possibly pull out the lat/long as well.
关于如何使用 map/reduce 来完成此任务的任何建议?我觉得它很基础,我就是想不通.
Any advice on how to use map/reduce to accomplish this? I feel like it's rather basic, I just can't figure it out.
推荐答案
我没有任何 PHP 经验,但是如果你想了解 MongoDB Map-Reduce 是如何工作的,那么你可以看看这个..
I don't have any experience in PHP, but if you wanted to learn how MongoDB Map-Reduce works, then you can check this out..
有关更多信息,请查看 this
For more info, check out this
这篇关于如何在 MongoDB 中使用 Map/Reduce?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 MongoDB 中使用 Map/Reduce?


基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01