

How to MapReduce collection to join an array of all values in the field contai...
source link: https://www.codesd.com/item/how-to-mapreduce-collection-to-join-an-array-of-all-values-in-the-field-containing-the-array.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to MapReduce collection to join an array of all values in the field containing the array
I have the following schema in the database:
{
id: 12345;
friends: [123,345,678,908]
},
{
id: 908;
friends: [123,345]
}
Is there a way to get an array of all unique friends IDs from the entire collection?
To get distinct friends values you do not need to write map/reduce job.
Just run:
> db.collection.distinct("friends")
[ 123, 345, 678, 908 ]
Related Articles
Numpy 2D array: change all values to the right of NaNs
How to combine a constant string with all values in the array?
Pass all values from the second table into the inner join
How to search multiple sets of data for columns and values in the mysql query
VB.NET - How can I parse a string with X Y Z values in the disorder?
How do you subdivide a data frame that has different values for the same two columns in R
SQL join returns all values in the wrong table
How do I apply a grayscale CSS3 filter to all properties except the figcaption tag?
SAS - Grouping by ID, how to convert all values to the minimum value of 1 lines?
How do I write a DATA step that removes all variables from the input dataset except those that I explicitly set in the dataset?
How to calculate all values in the Bootstrap column and display in the footer of the table
How to cut a Pandas data frame by column header value when the column header is a date-time value?
Oracle aggregation functions and how to concatenate all values in the column
How to join several criteria, returning all combinations of the two criteria
Recommend
-
7
Technical Articles
-
8
欧雷说:「reset -> default values (from data type or field)r...」 欧雷 发表于 2021-11-12 12:47 reset -> default values (from data type or field)r...
-
8
Use elastic search aggregations on script_field values? advertisements I have created groovy script to calculate new field...
-
9
How to write an SQL query to identify duplicate values in a specific field? advertisements This is the table I'm working...
-
8
midoliy🍀Tatsuya Midorikawa on Twitter: "🔹Release : Funtom.Linq v0.0.7 --- Reimplemented: Don’t miss what’s happeningPeople on Twitter are the first to know.
-
11
How to select the item in Protractor by the html attribute when the value contains advertisements Struggling with how to se...
-
6
Version hell with JSFUnit, Arquillian, and (embedded) Glassfish and other containers June 7, 2011
-
12
Using Power BI Field Parameters to translate Data and Values When building an enterprise reporting solution with Power BI, a question that always comes up is how to handle translations. Large...
-
5
Fermyon Built a WebAssembly Cloud to Push Serverless Microservices Beyond Containers Nov 20, 2022...
-
10
HTTP Structured Fields for PHP bakame/http-structured-fields is a framework-agnostic PHP library that allows you to parse, serialize build and update HTTP Structured Fields in PHP according to the
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK