Questions tagged [mongodb-aggregation]

MongoDB is a NoSQL database with the intent of storing billions of records. It offers the aggregation framework as a tool to manipulate and query records. This tag is intended to be used with question specific to this aggregation framework, since aggregation is too general.

147 questions
0
votes
1 answer

MongoDB aggregation pipeline PHP - $project previous stage without subarray

I have in my aggregation pipeline a subarray structure like this: { "_id": "london_10:2016-10-07 12", "data": { "voltage_a": 0.008888, "voltage_b": 0.008888, "voltage_c": 0.008888, }, "Voltage (V)": 0.008888, …
0
votes
2 answers

MongoDB Group by field and show array of grouped items?

I have a collection of Projects in where projects are like this: { "_id" : ObjectId("57e3e55c638cb8b971"), "allocInvestor" : "Example Investor", "fieldFoo" : "foo bar", "name" : "GTP 3 (Roof Lease)" } I want to receive a list of…
0
votes
1 answer

Scala, casbah aggregate query

I'm a newbie to MongoDB and Casbah and I'm wondering if anyone can help me please. I have the following mongoDB Query that works, db.getCollection('holidayRequests').aggregate ( [ { $match: { $and: [ { email: "leeroy.jenkins@company.com" }…
0
votes
0 answers

Spring data mongo aggregation mapping to object

I want to map the results of an aggregation to an POJO without iterating through the raw results. The POJO is a field in the Collection on which I'm running the aggregation. MatchOperation match =…
0
votes
1 answer

Can i aggregate two mongodb queries in one query using golang (mgo)?

I use golang and mgo, mongodb version is 3.2.9 For example i have two documents in one collection: {"groupId" : 4, "name" : "email", "value" : "11@11.com"} {"groupId" : 4,"name" : "phoneNumber","value" : "000000000"} I know phoneNumber (value…
0
votes
1 answer

MongoDB Aggregation command to Java code

This is my mongodb shell command: db.dais_employee.aggregate([ { "$redact": { "$cond": { "if": { "$gt": [ { "$subtract": [ "$modifiedon", "$createdon" ] }, …
0
votes
1 answer

Issue with $group command in MongoDB

I'm having an issue with Mongo DB where I am trying to group results using the command below. This maps to a Java object containing fields id, name and a list of results. However the name attribute will not map correctly for me.The $name attribute…
0
votes
1 answer

Mongo aggregation framework on big data

Could you please help me with mongoDB aggregation. Here is what I would like to do next: I have collection A. A document from A represents an object like: { nameA: 'first', items: [ 'item1', 'item2', 'item3', 'item4' ] } And I…
0
votes
0 answers

MongoDB aggregation framework to get frequencies of fields' values

I have a collection that is populated with documents that conform to the following schema: { _id, name: String, actionTime: Date, n1: Number, // 1<=n1<=10 n2: Number, // 1<=n2<=10 n3: Number // 1<=n3<=20 } I want to get the…
0
votes
2 answers

Count Elements SubDocument that match a given criterion

I have the following document structure in mongodb { "_id" : "123", "first_name" : "Lorem", "last_name" : "Ipsum", "conversations" : { "personal" : [ { "last_message" :…
Pila
  • 5,460
  • 1
  • 19
  • 30
0
votes
1 answer

mongodb aggregate with extra info

I have a mongo collection containing docs such as this: { "_id" : ObjectId("57697321c22d3917acd66513"), "parent" : "AlphaNumericID", "signature" : "AnotherAlphaNumericID", "price" : 1638, "url" :…
zevij
  • 2,416
  • 1
  • 23
  • 32
0
votes
0 answers

Filtering of subsubarrays

I have a collection: [ { "name": "Alex", "cars": [ { "label": "BMW", "age": 13, "things": [ ... ] }, { "label": "Mercedes", "age": 8, "things": [ ... ] } ] }, …
Kuraga
  • 331
  • 3
  • 16
0
votes
1 answer

Grouping of documents having the same phone number

My database consists of collection of a large no. of hotels (approx 121,000). This is how my collection looks like : { "_id" : ObjectId("57bd5108f4733211b61217fa"), "autoid" : 1, "parentid" : "P01982.01982.110601173548.N2C5", …
0
votes
1 answer

In MongoDB / mongoose sort and limit result of $push aggregate

I want to order and limit the results of and agregate, $group and $push. Let's say that I have a system with online orders. And I want to get a list with 3 most ordered products each year sorted by year and products amount. year product …
Mikel
  • 5,902
  • 5
  • 34
  • 49
0
votes
1 answer

MongoDB Aggregation for reshaping or grouping value to field names and month

My data is in the format: [{ _id: 1, Prom: "I", date: ISOdate(2016-01-01 ... ) }, { _id: 2, Prom: "P", date: ISOdate(2016-01-01 ... ) }, { _id: 3, Prom: "D", date: ISOdate(2016-02-01 ... ) }, { _id: 4, Prom: "I", date: ISOdate(2016-03-01 ...…
1 2 3
9
10