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 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
