6

How to MapReduce collection to join an array of all values ​​in the field contai...

 3 years ago
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.
neoserver,ios ssh client

How to MapReduce collection to join an array of all values ​​in the field containing the array

advertisements

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

Situation I have a 2D Numpy array that contains some nan values. Simplified example: arr = np.array([[3, 5, np.nan, 2, 4], [9, 1, 3, 5, 1], [8, np.nan, 3, np.nan, 7]]) which looks like this in console output: array([[ 3., 5., nan, 2., 4.], [ 9., 1.,

How to combine a constant string with all values ​​in the array?

I have a array like this: $arr = array( "0" => "Jack", "1" => "Peter", "2" => "ali" ); Now I want to add My name is: to the first of all those values...! How can I do that? Note: I can d

Pass all values ​​from the second table into the inner join

I have multiple inner joins on one table and I want to pass all values from second table column in where clause. e.g. select * from Table A inner join Table B on A.id = B.id inner join Table C on A.id = C.id Where C.somevalue = (all values from this

How to search multiple sets of data for columns and values ​​in the mysql query

jason data: avail":["Sun-2","Mon-2","Sun-3"] $avail = $data['avail']; //Below I'm categorizing values by morning, afternoon and evening. if($avail != ""){ foreach($avail as $k=>$v) { $v; //dividing value bef

VB.NET - How can I parse a string with X Y Z values ​​in the disorder?

I´m trying to write a parser that reads large files, try to locate X Y Z values on lines that can contain more registers than only X Y Z (Like M codes and other commands to drive CNC machines). I was successful in reading the code and separating data

How do you subdivide a data frame that has different values ​​for the same two columns in R

I have this data frame: dput(df) structure(list(Metrics = c("db1.Tablespace_Space_Used_(%)", "db1.Tablespace_Space_Used_(%)", "db1.Tablespace_Space_Used_(%)", "db1.Tablespace_Space_Used_(%)", "db2.Tablespace_Sp

SQL join returns all values ​​in the wrong table

I am new to SQL and I cannot figure out why my SQL result returns all data from the wrong table. I want to receive all data from product table but I want to filter the results so it does not show those results that have some value in another table. M

How do I apply a grayscale CSS3 filter to all properties except the figcaption tag?

How do I apply CSS3 webkit-filter grayscale to all article tags except the <figcaption> tag? Look at this jsfiddle for an example. .black-white { filter: grayscale(1); -webkit-filter: grayscale(1); transition: all 0.3s ease-out !important; -webkit-t

SAS - Grouping by ID, how to convert all values ​​to the minimum value of 1 lines?

I want an data-step or SQL statement to do the following. Consider this table: (Before) id div dlenfol repurch rlenfol 1 0 145 1 25 2 0 114 0 114 2 0 114 0 114 3 0 189 1 53 3 0 189 0 189 3 1 149 0 189 4 1 14 0 182 4 0 182 1 46 4 0 182 0 182 Grouping

How do I write a DATA step that removes all variables from the input dataset except those that I explicitly set in the dataset?

I want to generate a new SAS dataset using table foo as the input and one-to-one correspondence with records in the output dataset bar. I wand to drop variables from foo by default but I also require all of the fields of foo be available (to derive n

How to calculate all values ​​in the Bootstrap column and display in the footer of the table

I have the following bootstrap Json table. Fiddle I want to add all the values in the stars Columns and | Name | Stars | Forks | Total Stars $832 Total Forks $456 Display in the table as "Total Stars" etc How can I add the column and display the

How to cut a Pandas data frame by column header value when the column header is a date-time value?

I have an excel file where the column name consists of date-time value. As you can see the header value is in date-time format. I have loaded this to Pandas dataframe and the header values are indeed saved as date-time value. Now if I need to query f

Oracle aggregation functions and how to concatenate all values ​​in the column

All, My Oracle Database is version 10g Enterprise Edition Release 10.2.0.5.0 - 64bit I have the following statement which usefully gets me the max (or min or count etc) values in each case as expected however what I would like is to get and to concat

How to join several criteria, returning all combinations of the two criteria

I am willing to bet that this is a really simple answer as I am a noob to SQL. table 1 has column 1 (criteria 1) column 2 (criteria 2) column 3 (metric 1) table 2 has column 1 (criteria 1) column 2 (criteria 2) column 3 (metric 2 specific to table2.c

Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK