Questions tagged [nosql-aggregation]

Questions related to Aggregation functions in NoSQL databases.

Questions related to Aggregation functions such as Count() or Sum() in NoSQL databases.

313 questions
0
votes
1 answer

How to query a collection in Firestore and aggregate the documen into `per day`, `per week`?

My goal is to aggregate the document into per day, per week. document template stored in Firestore. document = { iat: new Date() // Wed Aug 26 2020 HH:MM:SS GMT+... (... Time), bill: PropTypes.number, } The expected output is data = { labels:…
0
votes
1 answer

Retrieve and display data from Array Document

This is my example document : { _id:1, name:Dennis, tasks:[{ task:'Drawing', dateFinished: Date() },{ task:'Paint', dateFinished: Date() }] } I want to get the data from my document and display it like this, sorted by…
0
votes
0 answers

How to use multiple condition in mongoDb query?

Write query to find the restaurant Id, name, and grades for those restaurants which achieved a grade of "A" and scored 11 on an ISODate "2014-08-11T00:00:00Z" among many of survey dates.. *My answer is as : db.resCollec.find( { "grades.date":…
0
votes
1 answer

Aggregation server side with sakulstra/meteor-aggregate returns: "xxxx.Aggregation is not a function"

I just want a simple grouping. I installed the aggregation function with meteor add sakulstra:aggregate but in every case it returns TypeError: Respuesta.aggregate is not a function I'm using Meteor 1.10.2 and React. This is my server side…
TOTΣM
  • 47
  • 1
  • 7
0
votes
1 answer

Setting condition in aggregate pipeline not working in mongodb

I have got two collections as follows: Users: _id | email ObjectId("5ee493b0989d0f271cdc41c1") | joulie@gmail.com ObjectId("5ee493b0989d0f271cdc41c3") | …
0
votes
1 answer

MongoDb add $avg element of an array in an array by $map mapping

Problem is that I want to 'enter' array utwor and count average of dlugosc_utworu How looks my code: db.artysci.aggregate({ "$project": { _id: 0, nazwa: 1, nazwisko: 1, "numberOfSongs": { "$sum": { …
0
votes
3 answers

MongoDb count elements of array in array by $size

I need help to count the elements of an array when it is in another array. My command, when I tried to select the second array is, db.artysci.aggregate([ { $project: { _id:0, nazwa: 1, nazwisko: 1, …
0
votes
0 answers

Need a database for key-array storage with array specific operations like "update union" and sub-array selection

I need a database to store pairs of key - array rows like below: ===== TABLE: shoppingCart ===== user_id - product_ids 1 - [1, 2, 3, 4] 2 - [100, 200, 300, 400] and I want to be able to update a row with new array merging to the old one…
0
votes
1 answer

BigQuery - Aggregate rows using standard SQL

Consider this table +------------+----------------+-------------+ | date | region_name | population | +------------+----------------+-------------+ | 2000-02-11 | Lower Normandy | 1.000.000…
SubZeno
  • 341
  • 3
  • 15
0
votes
1 answer

$project $lookup value not shown after $group

I have 2 related collection which i want to do a $lookup. switches { "_id" : ObjectId("5e8453c095c85ca0c33a9461"), "device_id" : ObjectId("5e7d83efd62c242a11e3ca5e"), "relay" : NumberInt(1), "name" : "Lampu Tengah", …
Vicky Sultan
  • 73
  • 2
  • 15
0
votes
1 answer

How do I add a condition to ElasticSearch Aggregation (min/max)?

I want to query to my Elastic-Search to get minimum price of values which have only positive value. My prices can also be zero and -1; so I don't want my min-aggregation to return 0 or -1. I know that I should add a script to the query (or filter),…
0
votes
0 answers

How to count the number of $groups in a aggregation?

I am querying my mongodb and ask for an aggregation. I would like to get the number of $groups that are output. What is the best way to do so ? Haven't figured out yet My request is currently : db.getCollection('tickets').aggregate({ $match:…
phenetas
  • 117
  • 1
  • 8
0
votes
2 answers

How can i find the index of an array element that is a dictionary based on one of the keys of the dictionary using mongo query?

"_id" : ObjectId("5de64d7802a3414fbf374e75"), "sectionDTO" : { "sectionData" : [ { "type" : "PRODUCT", "title" : "What is Proburst BCAA supreme?", "description" :…
0
votes
1 answer

MongoDB Shell How can I average or $min/$max a sum of strings

I've been trying to get my head around aggregation for a while now and I can't seem to work out how to find the average, min or max, of a sum of strings. db.mycollectionname.aggregate([ {$unwind: "$Monitor"}, {$group: {_id:…
0
votes
1 answer

group by 3 tables and count in empty functions the same as empty tables mongoDb

` this is my document: i want to group by storeId,and 3 arrays diag.webForWeb, diag.webForStore and diag.storeForStore and make a count even empty array: something like that. storeId; businessRulesWebForStore ; (vide); 100 $storeId;…